Skip to content

Instantly share code, notes, and snippets.

View Micka33's full-sized avatar

Mickaël CASSY Micka33

View GitHub Profile
@Micka33
Micka33 / railsConsole.rb
Last active December 28, 2015 02:39
how to go through RIAKCS&RIAK to manage files
# Create a user in RIAK & RIAKCS
# Get the user
Me = User.find_by_index(:email, "mickael3@beingenious.com")
Me = User.find '52820a5994da266b19000002'
# Or create a new one
Me = User.new username:'Micka2', email:'mickael2@beingenious.com', firstname:'micka2', lastname:'cassy2', password:'testtest2', password_confirmation:'testtest2'
Me.save
# In RIAKCS, Use FOG
# Instanciate the Fog API to go through RIAKCS
s3 = Fog::Storage.new RiakCS::BucketManager.get_credentials(Me.key_id, Me.key_secret)
@Micka33
Micka33 / full_ffmpeg_and_imagemagick.sh
Last active December 30, 2015 20:19
Install ffmpeg and imagemagick on ubuntu (pretty ugly but it should do it)
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm
./configure
make
sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no --deldoc=yes --fstrans=no --default
apt-get -y install autoconf automake build-essential checkinstall git libass-dev libfaac-dev libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libspeex-dev libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
aptitude install checkinstall
@Micka33
Micka33 / markdown.md
Last active December 31, 2015 14:49
markdown.md

TITRE 1

SOUS TITRE 2

du code

point d'eclamation

du texte normal avec un retour.
a la ligne

@Micka33
Micka33 / resize.py
Created January 14, 2014 08:48
script using imageMagic to resize only the images that are bigger than 1460x841
import os
from subprocess import call
import time
from datetime import datetime
import calendar
import re
##
@Micka33
Micka33 / codewars.rb
Created January 28, 2014 14:58
codewars exemple
#Subject
#Find the sum of the digits of all the numbers from 1 to N (both ends included).
#For N = 10 the sum is 1+2+3+4+5+6+7+8+9+(1+0) = 46
#For N = 11 the sum is 1+2+3+4+5+6+7+8+9+(1+0)+(1+1) = 48
#For N = 12 the sum is 1+2+3+4+5+6+7+8+9+(1+0)+(1+1) +(1+2)= 51
#Supported Ruby version is 1.9.3
#Tests
it 'should' do
Test.assert_equals(solution(10), 46)
def snail(array)
x = 0
y = 0
done = []
indexes = [[1,0],[0,1],[-1,0],[0,-1]].cycle
delta = indexes.next
res = []
array.flatten.length.times do |n|
res << array[y][x]
done << x.to_s+y.to_s
@Micka33
Micka33 / walk.py
Last active August 29, 2015 13:56
Iterate through folders and files
#!/usr/bin/env python2
import os
def callfn(fns, name, path, dry):
if isinstance(fns, list):
for fn in fns:
if hasattr(fn, '__call__'):
fn(name, path, dry)
elif hasattr(fns, '__call__'):
fns(name, path, dry)
@Micka33
Micka33 / download.sh
Last active August 3, 2018 03:04
Download/install Nginx +some convenient modules (rtmp/lua5.1/upstream-fair/ssl/etc) on Ubuntu
wget http://nginx.org/download/nginx-1.4.5.tar.gz
tar xzf nginx-1.4.5.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
tar xzf zlib-1.2.8.tar.gz
wget http://downloads.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fpcre%2Ffiles%2Fpcre%2F8.34%2F&ts=1393362418&use_mirror=kent
mv pcre-8.34.tar.bz2\?r\=http\:%2F%2Fsourceforge.net%2Fprojects%2Fpcre%2Ffiles%2Fpcre%2F8.34%2F pcre-8.34.tar.bz2
tar xjf pcre-8.34.tar.bz2
@Micka33
Micka33 / test_riak-cs.md
Last active August 29, 2015 13:57
Test riak-cs

Substitute riak-cs by netcat to vatch the sent request

$> nc  -l 127.0.0.1 8080
PUT /53208b5294da268379000001?AWSAccessKeyId=O_5H9U1UTJNVB5MDNM0O&Expires=1394677746&Signature=IjMEUg%2BH%2FP7SP5nx4KW7gXJ6h8g%3D HTTP/1.1
Host: 52aed41a94da26d8fa000001.data.riak.dev
Content-Length: 2831
x-amz-acl: public-read
...
@Micka33
Micka33 / socketio.js
Created April 10, 2014 09:43
Angularjs wrapper for socket.io
admin.factory('$socket', ['$rootScope', function ($rootScope) {
if (typeof io != 'undefined')
var socket = io.connect();
return {
connect: function (url) {
if (typeof io != 'undefined')
socket = io.connect(url);
},
on: function (eventName, callback) {
if (typeof socket != 'undefined')