Skip to content

Instantly share code, notes, and snippets.

@willrax
willrax / my_scene.rb
Last active August 29, 2015 14:01
Parallax scrolling with Sprite Kit and RubyMotion
# Video of it in action: http://cl.ly/VSIF
class MyScene < SKScene
def scroll_action(x, duration)
width = (x * 2)
move = SKAction.moveByX(-width, y: 0, duration: duration * width)
reset = SKAction.moveByX(width, y: 0, duration: 0)
SKAction.repeatActionForever(SKAction.sequence([move, reset]))
end
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
+ (NSString*)hmacsha1Hexdigest:(NSString*)data key:(NSString*)key
{
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
const char *cData = [data cStringUsingEncoding:NSUTF8StringEncoding];
uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};
CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), digest);
@r3econ
r3econ / ALAssetsLibrary+VideoOrientation.h
Created March 25, 2014 19:34
ALAssersLibrary category for getting the video's orientation.
@interface ALAssetsLibrary (VideoOrientation)
+ (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset;
@end
@miohtama
miohtama / gist:0f64104fc8aefde8360f0c70cf46b950
Last active January 22, 2017 14:00
SMS based login for React and Websauna app
"""
allows users to sign up and login with their phone number, if that number is assoicated with an
existing customer record.
"""
import logging
import colander
from cornice.service import Service
from pyramid.exceptions import HTTPBadRequest
from pyramid_sms.utils import normalize_us_phone_number
## ffmpeg encoding for Twilio, Genesys and other voice delivery platforms
## File input can be any format ffmpeg accepts (.mp3, .wav, .avi, etc.), output shout should be .wav format
ffmpeg -i "YOUR_INPUT_FILE.m4a" -ar 8000 -ac 1 -ab 64 -acodec pcm_mulaw "YOUR_OUTPUT_FILE.wav" -map 0:0
'''
Easy Mac
Copyright (2015) Sean Beck
Licensed under Creative Commons Attribution-ShareAlike 4.0 International
See: https://creativecommons.org/licenses/by-sa/4.0/
Easily change your MAC address on Linux using `ifconfig`
'''
#!/usr/bin/python2.7
anonymous
anonymous / scrypt_password.py
Created September 26, 2013 13:54
An answer to http://stackoverflow.com/questions/13654492/how-to-use-scrypt-to-generate-hash-for-password-and-salt-in-python How to generate and check a password hash with scrypt and python.
import struct
from binascii import b2a_base64 as e64
from binascii import a2b_base64 as d64
import scrypt
import Crypto.Random
random = Crypto.Random.new().read
from passlib.utils import consteq
_PARAMS = struct.Struct("!BBBB")
global
lua-load /usr/local/etc/haproxy/acme-http01-webroot.lua
ssl-default-bind-ciphers AES256+EECDH:AES256+EDH:!aNULL;
tune.ssl.default-dh-param 4096
debug
defaults
mode http
option log-health-checks
option dontlognull
const path = require('path');
const glob = require('glob');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const css_loaders = [
@fdcore
fdcore / uuid.php
Last active March 2, 2019 03:26
Encode long UUID to short binary string like youtube hash
<?php
// echo uuid_encode('cd76b808-4017-4965-b9b1-2dbcf857e405');
function uuid_encode($uuid){
$binary = pack("h*", str_replace('-', '', $uuid));
$binary = base64_encode($binary);
$binary = str_replace('/', '_', $binary);
$binary = str_replace('=', '', $binary);
return $binary;