Skip to content

Instantly share code, notes, and snippets.

View zorbash's full-sized avatar
👨‍💻
'); DROP TABLE recruiters;

Dimitris Zorbas zorbash

👨‍💻
'); DROP TABLE recruiters;
View GitHub Profile
#!/home/agorf/.rbenv/shims/ruby
require 'json'
workspaces = JSON.load(`i3-msg -t get_workspaces`)
num = ((1..10).to_a - workspaces.map {|w| w['num'] }).min
exec "i3-msg workspace #{num}"
debounce: function(func, wait, immediate) {
if (typeof wait != 'number') {
wait = DEFAULT_INTERVAL;
}
var timeout, result;
return function() {
var context = this, args = arguments;
var later = function() {
@zorbash
zorbash / map_caps_to_esc.sh
Last active December 23, 2015 00:09
Map your caps key to esc
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' # map caps to escape
setxkbmap -option ctrl:nocaps #disable caps default functionality
setxkbmap -option grp:alt_shift_toggle us,gr # map alt shift to layout toggle
@zorbash
zorbash / keyboard
Last active December 24, 2015 01:39
/etc/default/keyboard
XKBMODEL="pc105"
XKBLAYOUT="us,gr"
XKBVARIANT=""
XKBOPTIONS="grp:alt_shift_toggle caps:escape"
crash.log
.ruby-version
.ruby-gemset
oauth.yml
tmp
@zorbash
zorbash / nginx.conf
Last active August 29, 2015 13:56
nginx + mruby experiment, /songs/random endpoint.
server {
location /songs/random {
mruby_content_handler '/var/www/apps/songs/random.rb';
}
location /words/random {
mruby_content_handler '/var/www/apps/words/random.rb';
}
}
@zorbash
zorbash / random.rb
Created February 24, 2014 21:16
ngix + mruby experiment
begin
word = `shuf /usr/share/dict/words | head -1`.chomp
Nginx::rputs JSON::stringify({ word: word})
rescue Exception => e
Ngixn::rputs e
end
@zorbash
zorbash / sinatra_random.rb
Last active August 29, 2015 13:56
experiment with sinatra
require 'sinatra'
require 'json'
require 'sqlite3'
get '/songs/random' do
db = SQLite3::Database.new '/var/www/apps/shared/songs.db'
row = db.execute('SELECT * FROM songs ORDER BY RANDOM() LIMIT 1;')[0]
song = {
id: row[0],
@zorbash
zorbash / express_random.js
Created February 24, 2014 23:15
Example api with nodejs and express framework
express = require('express');
sqlite3 = require('sqlite3').verbose();
http = require('http');
exec = require('child_process').exec;
db = new sqlite3.Database('/var/www/apps/shared/songs.db');
app = express();
app.listen(9999);
@zorbash
zorbash / main_controller.rb
Created February 25, 2014 00:19
Example api with plain RoR
class MainController < ApplicationController
def songs_random
row = ActiveRecord::Base.connection
.execute("SELECT * FROM songs ORDER BY RANDOM() LIMIT 1;")[0]
render json: { song: row.delete_if { |key, _| key.to_s =~ /^[0-9]+$/ } }
end
def words_random
render json: { word: `shuf /usr/share/dict/words | head -1`.chomp }