All posts by kit

wordpress and HTTPS

– Cloudflare: add page rules for https://kitwestneat.com/wordpress/wp-admin* and https://kitwestneat.com/wordpress/wp-login* to have full SSL

– WordPress: add $_SERVER[‘HTTPS’] = ‘on’; to wp-config
– WordPress: change addresses in general settings
– Cloudflare: set site wide SSL to flexible
– Cloudflare: set Always use HTTPS on
– Monitis: enable SNI, make sure URL is not using :80

Simple GraphQL server tutorial

https://medium.com/@gethylgeorge/setting-up-a-simple-graphql-server-with-node-express-and-mongoose-ff8a1071af53

http://graphql.org/graphql-js/graphql-clients/

passport with graphql tutorial:
https://dev-blog.apollodata.com/a-guide-to-authentication-in-graphql-e002a4039d1

Mongoose Auth tutorial:
https://www.mongodb.com/blog/post/password-authentication-with-mongoose-part-1

Apollo Graphql client:
https://github.com/apollographql/apollo-client

JS Excercises

Some exercises that might be fun to try sometime:
https://github.com/kolodny/exercises

Kind of remind me of Project Euler:
https://projecteuler.net/

This is a fun reverse engineering thing:
https://www.alexkras.com/reverse-engineering-one-line-of-javascript/

another framework

React Starter Kit:
https://github.com/kriasoft/react-starter-kit/blob/master/docs/getting-started.md

There’s so much going on with it, it’s hard to know where to start.

Passport:
It looks like by default it uses a Facebook login via Passport.
https://github.com/jaredhanson/passport-facebook

Sequelize:
The starter kit uses sequelize to do DB operations with an RDBS.
http://docs.sequelizejs.com/

FB OG framework:
https://github.com/facebookincubator/create-react-app

It uses a service worker to cache static assets, that’s kind of interesting:
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app

gatsby react framework

Gatsby react framework, worth trying out on the next React app:
https://www.gatsbyjs.org/

Counterintuitive probability about wealth distribution:
http://www.decisionsciencenews.com/2017/06/19/counterintuitive-problem-everyone-room-keeps-giving-dollars-random-others-youll-never-guess-happens-next/

“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.”
https://en.wikiquote.org/wiki/Bjarne_Stroustrup

Kebabs are the best, jingoism is dumb
https://www.citylab.com/life/2017/07/frances-crackdown-on-kebabs/533091/?utm_source=SFTwitter

Automatic photo capturing

Steps:
1) detect camera is attached
2) capture images
3) copy image to movie dir and add name to image manifest
4) trigger upload
5) move image to backup folder
6) add cron job to make movie

Detecting camera is attached

USB hotplug events are handled by udev.

Here’s how you monitor udev events to write a rule:
udevadm monitor

Get USB bus info with:
lsusb

You can list udev attributes for a device with:
udevadm info -a -p $(udevadm info -q path -n /dev/bus/usb/001/003)

Example rule:
SUBSYSTEMS==”usb”, ATTRS{product}==”Some FooDev”, RUN+=”/pathto/script”

https://unix.stackexchange.com/questions/28548/how-to-run-custom-scripts-upon-usb-device-plug-in
http://weininger.net/how-to-write-udev-rules-for-usb-devices.html

Capture images

gphoto2 can capture images from a USB connected camera and trigger an event when download. The easiest mode seems to be –capture-image-and-download. There’s an interval setting (-I) as well that will allow continuous downloads every x seconds. The –hook-script allows you to execute a script when the image is downloaded. The –filename option can set a filename pattern, but it doesn’t allow %s.

Resources:
http://www.gphoto.org/doc/manual/ref-gphoto2-cli.html
http://www.gphoto.org/doc/manual/using-gphoto2.html
http://www.gphoto.org/doc/manual/
http://photolifetoys.blogspot.com/2012/08/control-your-camera-with-gphoto2-via.html

Upload images to tumblr

This is fairly straightforward with the tumblr.js node library:

client = tumblr.createClient({api keys});

client.photo(blogname, { 'state': 'published', 'tags': tags, 'data': fullpath }, function(err) {
if (err) {
console.log(err);
process.exit(1);
}
});

The only tricky thing is that if you upload too quickly then tumblr will block you. Once every 10 minutes seems good. Maybe a cron job is the best way to do the rate limiting?

Creating movies

Before uploading to tumblr, copy files to movie directory and if the time is in the 14h window, add filename to the image list for ffmpeg.

You can do something like this in ffmpeg to read in a list of image filenames and create a film:
cat $(cat manifest) | ffmpeg -framerate $in_fr -i – -r $out_fr -preset ultrafast $out_file

NAND Logic Equivalents

P||Q = !P|!Q = (P|P)|(Q|Q)
P&&Q = !(P|Q) = (P|Q)|(P|Q)
P|!Q = P|(P|Q) = P|(Q|Q) = !P || Q

P xor Q = (P|(P|Q))|(Q|(P|Q))
– (P && !Q) || (!P && Q))
– !(P|!Q) || !(!P|Q)
– (P|!Q)|(!P|Q)
= (P|(P|Q))|(Q|(P|Q))

S mux PQ = (!S|P)|(S|Q)
– (!S && P) || (S && Q)
– !(!S|P) || !(S|Q)
= (!S|P)|(S|Q)