Skip to content

Instantly share code, notes, and snippets.

@joequery
joequery / pubkey.md
Last active October 21, 2015 19:54
Public Key Encryption

Public Key Encryption

Let:

  • t = the plaintext (the text we want to send)
  • p = the public key, whose secret key is s.
  • s = the secret key, whose public key is p
  • c = The cypher text (AKA the encrypted string)
@joequery
joequery / sort.c
Created October 12, 2015 08:00
Recursive C Insertion Sort
#include<stdio.h>
#define ARR_SIZE 6
void print_r(int *arr, size_t n);
void insertion_sort(int *arr, size_t n, size_t i);
int main(){
int nums[ARR_SIZE] = {2,8,9,0,0,2};
print_r(nums, ARR_SIZE);
@joequery
joequery / sort.php
Created October 12, 2015 07:56
Recursive PHP Insertion Sort
<?php
function insertion_sort($a, $n, $i){
if($i == $n-1){
// Nothing to do since we're looking at the last element. Just return
// the array as-is.
return $a;
}
else{
$sorted = insertion_sort($a, $n, $i+1);
@joequery
joequery / dropbox_64.sh
Last active August 29, 2015 14:27
Install Dropbox on 64 bit Ubuntu Server
#!/bin/bash
cd
wget "https://www.dropbox.com/download?plat=lnx.x86_64" -O dropbox.tar
tar -zxf dropbox.tar
wget "https://www.dropbox.com/download?dl=packages/dropbox.py" -O dropbox
chmod +x dropbox
sudo mv dropbox /usr/local/bin
~/.dropbox-dist/dropboxd
@joequery
joequery / ordered_dict.py
Last active February 3, 2021 09:33
Python 3.5.0b1 OrderedDict implementation
# Located in Lib/collections/__init__.py
################################################################################
### OrderedDict
################################################################################
class _OrderedDictKeysView(KeysView):
def __reversed__(self):
yield from reversed(self._mapping)
@joequery
joequery / gist:1016eb3d90fa99b3a1c5
Created March 18, 2015 07:59
Forcast IO sample data
{"latitude":30.3389,"longitude":-97.7707,"timezone":"America/Chicago","offset":-5,"currently":{"time":1426665547,"summary":"Drizzle","icon":"rain","nearestStormDistance":0,"precipIntensity":0.0059,"precipIntensityError":0.0009,"precipProbability":0.62,"precipType":"rain","temperature":66.78,"apparentTemperature":66.78,"dewPoint":64.57,"humidity":0.93,"windSpeed":3.16,"windBearing":163,"visibility":8.67,"cloudCover":0.87,"pressure":1016.84,"ozone":303.07},"minutely":{"summary":"Drizzle stopping in 5 min., starting again 20 min. later.","icon":"rain","data":[{"time":1426665540,"precipIntensity":0.0059,"precipIntensityError":0.0009,"precipProbability":0.62,"precipType":"rain"},{"time":1426665600,"precipIntensity":0.0054,"precipIntensityError":0.0012,"precipProbability":0.56,"precipType":"rain"},{"time":1426665660,"precipIntensity":0.0055,"precipIntensityError":0.0013,"precipProbability":0.56,"precipType":"rain"},{"time":1426665720,"precipIntensity":0.0053,"precipIntensityError":0.0016,"precipProbability":0.5,"p
@joequery
joequery / toggle_touch.bat
Created June 30, 2014 01:51
Windows 8 batch file to toggle touch screen functionality
set "touchscreenid=YOUR_TOUCHSCREEN_HARDWARE_ID_HERE"
devcon status "%touchscreenid%" | findstr "running"
if %errorlevel% == 0 (
devcon disable "%touchscreenid%"
) else (
devcon enable "%touchscreenid%"
)
@joequery
joequery / dynamic_router.py
Last active August 29, 2015 14:02
DynamicRouter - Django Rest Framework
from rest_framework import routers
import inspect
class DynamicRouter(routers.DefaultRouter):
def get_routes(self, viewset):
"""
Augment `self.routes` with any dynamically generated routes.
Returns a list of the Route namedtuple.
"""
@joequery
joequery / gist:9779390
Last active August 29, 2015 13:57
FFmpeg concatenation
# ffmpeg -i ../codervox-fadeout.mp4 -i transition.mp4 -i themovie.mp4 -filter_complex '[0:v][0:a][1:v][1:a][2:v][2:a] concat=n=3:v=1:a=1 [v][a]' -map '[v]' -map '[a]' -c:v libx264 output.mp4
@joequery
joequery / gist:9778764
Last active August 29, 2015 13:57
FFmpeg - fade in a video (first few seconds)
# ffmpeg -i fademe.mp4 -filter_complex "[0:v] fade=in:st=0:d=1[ov]" -map "[ov]" -c:v libx264 -t 2 transition.mp4; ffmpeg -f lavfi -i aevalsrc=0 -i transition.mp4 -vcodec copy -acodec aac -map 0:0 -map 1:0 -shortest -strict experimental -y transition.mp4