Skip to content

Instantly share code, notes, and snippets.

View xlab's full-sized avatar
:octocat:
Hacking

Max Kupriianov xlab

:octocat:
Hacking
View GitHub Profile
John Carmack on shadow volumes...
I recieved this in email from John on May 23rd, 2000.
- Mark Kilgard
I solved this in a way that is so elegant you just won't believe it. Here
is a description that I posted to a private mailing list:
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
// @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella
// and myself.
@xlab
xlab / Test
Created August 23, 2013 15:18
<?php
$link = mysql_connect('localhost','root','');
mysql_select_db('bd_rbt');
mysql_set_charset('utf8');
class Uploader
{
public $upload_dir = "Z:\\home\\myrbt.ru\\www\\files\\";
private $allow_exp = Array("image/jpeg", "image/png");

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

1. Open a command prompt and navigate to /etc/nginx/ssl
2. issue "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"
3. Get your certificate - Go to your certificate authority and give them the CSR
4. copy your new crt to the /etc/nginx/ssl and give it read priveledges
5. reconfigure your nginx.conf, here is mine. The first part redirects 80 to 443, the second part listens to 443 and is optimized to return Ruby on Rails application requests using gzip and unicorn.
function createWebSocket () {
var connection = new WebSocket();
var attempts = 1;
connection.onopen = function () {
// reset the tries back to 1 since we have a new connection opened.
attempts = 1;
// ...Your app's logic...
}
@xlab
xlab / Dockerfile
Last active August 29, 2015 14:08 — forked from lox/Dockerfile
FROM progrium/busybox
ADD https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt /etc/ssl/ca-bundle.pem
1. Founder has all permissions.
2. Everyone in the chatroom can verify that public key X is indeed founder's key, it's a property of the chatroom and no peer stores it i.e. the chatroom itself contains that information somewhere, presumably in its ID (we don't rely on chatroom peers storing that data because they can came up with whatever they want i.e. say that the key X is not founder's key; we want that verification to be 100% exact and to work with even 1 peer in the chatroom).
3. To give permissions to user A, founder gives user A data which tells what permission level does A have (if we are going to have permission levels in tox at all). The data is signed by founder's private key.
4. Now A can show anyone that signed by founder data from the step (3) as a proof of her having permissions (anyone can verify that it was indeed signed by founder by (2)), so A can exercise her rights over everyone in the chatroom.
5. If A gives permissions to B, 1) A sends her founder-signed data to B to show that she i
@xlab
xlab / gist:e21f535ac45a42cb937c
Last active August 29, 2015 14:27 — forked from davecheney/gist:6740651
gccgo on armv7
localhost(~/src) % gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/opt/libexec/gcc/arm-linux-gnueabihf/4.8.2/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../gccgo/configure --prefix=/opt --enable-languages=c,c++,go --with-ld=/usr/bin/ld --enable-shared --without-included-gettext --enable-threads=posix --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --with-system-zlib --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.8.2 20130927 (prerelease) (GCC)
localhost(~/src) % go run -compiler gccgo helloworld.go
Hello gccgo
@xlab
xlab / GoWithC.go
Last active September 2, 2015 20:31 — forked from 17twenty/GoWithC.go
Cross Compiling and Language Interop oh my!
package main
import (
"./binding"
"fmt"
)
func main() {
binding.PrintHello()
binding.Seed(1)
fmt.Println(binding.Random())