Skip to content

Instantly share code, notes, and snippets.

View valryon's full-sized avatar
🤘

Damien Mayance valryon

🤘
View GitHub Profile
@RiANOl
RiANOl / gist:1077760
Last active April 13, 2024 06:17
AES128 / AES256 CBC with PKCS7Padding in Ruby
require "openssl"
require "digest"
def aes128_cbc_encrypt(key, data, iv)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
iv = Digest::MD5.digest(iv) if(iv.kind_of?(String) && 16 != iv.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.iv = iv
@codebutler
codebutler / JsonHelper.java
Created April 8, 2012 20:20
Convert Android JSONObject/JSONArray to a standard Map/List.
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;
public class JsonHelper {
public static Object toJSON(Object object) throws JSONException {
if (object instanceof Map) {
JSONObject json = new JSONObject();
@jboner
jboner / latency.txt
Last active April 24, 2024 00:20
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jotto
jotto / google_oauth2_access_token.rb
Created June 14, 2012 21:15
ruby command line script for generating google oauth2 access token
# (create oauth2 tokens from Google Console)
client_id = ""
client_secret = ""
# (paste the scope of the service you want here)
# e.g.: https://www.googleapis.com/auth/gan
scope = ""
@flarb
flarb / AssetGPULoader.cs
Created July 22, 2012 19:06
Unity3d GPU Pre-loader
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class AssetGPULoader : MonoBehaviour {
public Camera activeCamera;
RenderTexture _rt;
@solarsailer
solarsailer / osx_helpers.sh
Last active December 16, 2015 01:59
OSX Helpers
# Set the save dialog to be in extended mode by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
# Set the iCloud-using apps to not save to iCloud by default
# Courtesy of @room34, http://blog.room34.com/archives/5098
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Open a new document in TextEdit (& other iCloud-backed app) directly
# instead of presenting the document picker.
defaults write -g NSShowAppCentricOpenPanelInsteadOfUntitledFile -bool false
@shawndumas
shawndumas / .gitconfig
Created August 5, 2013 19:08
Using WinMerge as the git Diff/Merge Tool on Windows 64bit
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge
Shader "Sprites/Cutout"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.5
}

Application

Create an app with Automator that shows a notification and play a sound (available here).

Put it in your /Applications folder.

Scheduling

Type this in a shell:

@elisee
elisee / 1-terminal-windows.md
Last active June 8, 2019 21:12
Setting up a great console on Windows

The default console on Windows has many limitations!

  • No tabs, no split screen support
  • File and folder autocomplete doesn't stop when an ambiguity is reached
  • It doesn't append slashes when completing folder names which makes writing paths unnecessarily cumbersome

Solution: ConsoleZ + Clink