Skip to content

Instantly share code, notes, and snippets.

View solisoft's full-sized avatar
🏠
Working from home

BONNAURE Olivier solisoft

🏠
Working from home
View GitHub Profile
@solisoft
solisoft / server.cr
Last active August 13, 2017 05:25
multi rooms kemal websockets server
require "kemal"
require "json"
connected_sockets = {} of String => Array(HTTP::WebSocket)
connected_users = {} of String => Hash(String, JSON::Any)
def broadcast(data, sockets)
sockets.each do |socket|
socket.send data.to_json
end
@solisoft
solisoft / mustache_cr.cr
Created June 12, 2017 13:29
Compile mustache template
# Beware arguments have a limit size ...
require "./mustache_cr/*"
require "option_parser"
require "json"
require "crustache"
require "base64"
module MustacheCr
template = ""
json = {} of String => String
require 'net/http'
require 'json'
DB_USER = '<your_user>'.freeze
DB_PASS = '<your_password>'.freeze
DB_ENDPOINT = 'http+tcp://0.0.0.0:8529'.freeze
DUMP_PATH = '/path/to/your/dump/folder/'.freeze # must exist
DB_URL = 'http://0.0.0.0:8529'.freeze
uri = URI(DB_URL + '/_api/database')
var net = require('net');
var HOST = '127.0.0.1';
var PORT = 8888;
function rand(i) {
return parseInt((Math.random() * 10000) % i);
}
net.createServer(function(sock) {
var loadFields = function() {
// { r: new_row, c: classname, n: name/id, t: type, j: joi validation, l: label, d: data list }
fields = [
{ r: true, c: "1-1", n: "title", t: "string", j: joi.string().required(), l: "Title" },
{ r: true, c: "1-2", n: "date", t: "date", j: joi.string().required(), l: "Publishing Date" },
{ r: false, c: "1-2", n: "draft", t: "list", j: joi.string().required(), l: "Draft?", d: [["y", "Yes"], ["n", "No"]] },
{ r: true, c: "1-1", n: "text", t: "text", j: joi.string().required(), l: "Text"}
]
schema = {}
var loadFields = function() {
// { r: new_row, c: classname, n: name/id, t: type, j: joi validation, l: label, d: data list }
fields = [
]
schema = {}
each(fields, function(f) {
schema[f.n] = f.j
})
}
@solisoft
solisoft / github_user_filename.rb
Created August 9, 2016 04:39
Get Languages from User's git repositories
class Github
require 'net/http'
require 'json'
def initialize(login)
@login = login
end
def favourites_languages
json = load_json
@solisoft
solisoft / acme-client-runner.rb
Last active October 29, 2015 08:04 — forked from technion/acme-client-runner.rb
Runs Acme Client
#!/usr/bin/env ruby
require 'acme-client'
#Production
#ENDPOINT = 'https://acme-v01.api.letsencrypt.org'
#Testing
ENDPOINT = 'https://acme-staging.api.letsencrypt.org'
EMAIL = 'mailto:technion@lolware.net'
DOMAIN = 'lolware.net'
@solisoft
solisoft / install.sh
Created September 3, 2015 09:25
Install bridgeo on an Ubuntu 12.04 easily
# Based on Ubuntu 12.04 from OVH VPS
sudo aptitude update
aptitude install build-essential git git-core curl zlib1g-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties ruby redis-server memcached ruby-dev ufw htop fail2ban imagemagick libmagickwand-dev nodejs npm -y ruby libmysqlclient-dev
sudo echo "gem: --no-ri --no-rdoc" > ~/.gemrc
sudo gem install passenger -v 4.0.59
sudo passenger-install-nginx-module --auto --auto-download --languages 'ruby'
sudo gem install rails -v 2.3.15
sudo gem install atom -v 0.3
@solisoft
solisoft / nginx.conf
Created September 3, 2015 09:18
nginx basic conf file for bridgeo
user admin;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;