Skip to content

Instantly share code, notes, and snippets.

View darth30joker's full-sized avatar

Darth Joker darth30joker

View GitHub Profile
@darth30joker
darth30joker / Vagrant
Last active August 29, 2015 13:58
answer to simple-sinatra
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@darth30joker
darth30joker / pika-send.py
Last active August 29, 2015 14:04
It's an example of pika to send messages to rabbitmq
import pika
# create a connection for rabbitmq using localhost
connection = pika.BlockingConnection(pika.ConnectionParameters(
'localhost'))
channel = connection.channel() # create a channel
# declare an exchange
channel.exchange_declare(exchange='messages', type='direct')
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
'localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='messages', type='direct')
routings = ['info', 'warning', 'error']
# declare a queue to receive messages from exchange
[mysqld]
bind-address=0.0.0.0
console=1
general_log=1
general_log_file=/dev/stdout
log_error=/dev/stderr
collation-server=utf8_unicode_ci
character-set-server=utf8
#!/bin/sh
set -x
#apt-get update
#apt-get install -y unzip xz-utils curl bc git build-essential cpio gcc-multilib libc6-i386 libc6-dev-i386 kmod squashfs-tools genisoimage xorriso syslinux automake pkg-config
mkdir -p /workspace
export KERNEL_VERSION=3.15.3
export AUFS_BRANCH=aufs3.15
@darth30joker
darth30joker / gist:9e7ae8cdd842f6b8beca
Created August 25, 2014 09:02
Test what kind of programmers that you are
$ history | awk '{CMD[$2]++;count++;} END { for (a in CMD )print CMD[a] " " CMD[a]/count*100 "% " a }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
1 988 18.2692% ls
2 962 17.7885% docker
3 869 16.0688% git
4 588 10.8728% cd
5 151 2.79216% cat
6 150 2.77367% ssh
7 131 2.42234% subl
8 89 1.64571% vim
9 78 1.44231% rm
lxie:test3 git:(master*) $ grunt build
Running "clean:dist" (clean) task
Cleaning .tmp...OK
Cleaning dist/index.html...OK
Cleaning dist/scripts...OK
Cleaning dist/styles...OK
Running "jade:dist" (jade) task
>> 1 file created.
@darth30joker
darth30joker / calc.py
Created December 20, 2014 12:49
homework
#!/usr/bin/env python3
import re
import math
class CalculationException(Exception):
pass
class Calculation:
@darth30joker
darth30joker / Rakefile
Last active August 29, 2015 14:12
Ruby homework
task :default => :test
task :test do
sh 'rspec calc_spec.rb'
end
NUM = {
'1': 'one',
'2': 'two',
'3': 'three',
'4': 'four',
'5': 'five',
'6': 'six',
'7': 'seven',
'8': 'eight',
'9': 'nine',