This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'Base64' | |
key = "secret-key" | |
data = "some data to be signed" | |
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connection = Faraday::Connection.new('http://example.com') do |builder| | |
builder.request :url_encoded # for POST/PUT params | |
builder.adapter :net_http | |
end | |
# same as above, short form: | |
connection = Faraday.new 'http://example.com' | |
# GET | |
connection.get '/posts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 # From http://goldmann.pl/blog/2014/01/21/connecting-docker-containers-on-multiple-hosts/ | |
2 # Edit this variable: the 'other' host. | |
3 REMOTE_IP=192.168.0.103 | |
4 | |
5 # Edit this variable: the bridge address on 'this' host. | |
6 BRIDGE_ADDRESS=172.17.43.1/24 | |
7 | |
8 # Name of the bridge (should match /etc/default/docker). | |
9 BRIDGE_NAME=docker0 | |
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv/cv.h> | |
#include <opencv/highgui.h> | |
#include <opencv/ml.h> | |
void doMosaic(IplImage* in, int x, int y, | |
int width, int height, int size); | |
int main (int argc, char **argv) | |
{ | |
int i, c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# names of latest versions of each package | |
export VERSION_PCRE=pcre-8.38 | |
export VERSION_OPENSSL=openssl-1.0.2d | |
export VERSION_NGINX=nginx-1.9.7 | |
# URLs to the source directories | |
export SOURCE_OPENSSL=https://www.openssl.org/source/ | |
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ |
Reference: http://www.cnx-software.com/2012/07/31/84-mb-minimal-raspbian-armhf-image-for-raspberry-pi/
curl -O https://dl.dropbox.com/u/45842273/2012-07-15-wheezy-raspian-minimal.img.7z
yum install p7zip
7za e 2012-07-15-wheezy-raspian-minimal.img.7z
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda 2012-07-15-wheezy-raspian-minimal.img -net nic -net user -vnc :0 -net tap,ifname=vnet0,script=no,downscript=no
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
def hotp(secret, counter, digits = 6) | |
hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), secret, int_to_bytestring(counter)) | |
"%0#{digits}i" % (truncate(hash) % 10**digits) | |
end | |
def truncate(string) | |
offset = string.bytes.last & 0xf | |
partial = string.bytes[offset..offset+3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
def hotp(secret, counter, digits = 6) | |
hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), secret, int_to_bytestring(counter)) | |
"%0#{digits}i" % (truncate(hash) % 10**digits) | |
end | |
def truncate(string) | |
offset = string.bytes.last & 0xf | |
partial = string.bytes[offset..offset+3] |
If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8
To use the new phx.new
project generator, you can install the archive with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs
: