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
@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");
@xlab
xlab / gist:7156089
Last active December 26, 2015 13:09
Android.mk to build botan library within android/external
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := armeabi
LOCAL_NDK_VERSION := 5
LOCAL_SDK_VERSION := 9
LOCAL_NDK_STL_VARIANT := stlport_static
LOCAL_MODULE := botan

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 / gist:e09445cee8a25d07dd2a
Created May 1, 2014 00:37
.Property("ctrl")
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b5ea]
runtime stack:
runtime.panic(0x4f2760, 0x671578)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11
goroutine 4 [syscall]:
@xlab
xlab / gist:e3982b2f44319a44ebb9
Created May 1, 2014 00:39
.ObjectByName("ctrl")
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b60a]
runtime stack:
runtime.panic(0x4f2780, 0x671578)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11
goroutine 4 [syscall]:
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b8ea]
runtime stack:
runtime.panic(0x4f2980, 0x671578)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11
goroutine 4 [syscall]:
@xlab
xlab / smscloud.yaml
Last active August 29, 2015 14:04
cloud-configs
#cloud-config
hostname: smscloud1
ssh_authorized_keys:
- ssh-rsa: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDU/iKFrHQh6/y7QJyeVDJTUjD3u6dlhgLf2SE2pOfdIx9YL06zudlKikR5VekX2hEltdO87XTPOp/yCslC/dHMtndhYQV/gmlCQRbeugI7sg1FcCLjllA8Uiw5UskUUjas9Od1VACzLIC4E1u24JSCJTkz7IonhIrhWTcZAfGxIP/dVQqdBOFjNGSxjSoRZgHsQE8WMQ1oQqBIzZqre0f9VvaB6Q4zKSC0bOQR30CreB6+XdB6NsetQ9pwzQAswXtf1wSj8S8ekic1NCgont1SlxMmF6lH0gDVKNBXkC3o1X063N/N0IxypUdgxp7kzcca3kxv+bIsAeXylXRnmGH9
users:
- name: xlab
coreos-ssh-import-github: xlab
@xlab
xlab / products.go
Last active June 21, 2017 18:52
Example of calling the Google's Merchant API (content scope) from Go lang.
// Package products is an example of calling the Google's Merchant API (content scope) from Go lang.
package products
import (
"strconv"
"code.google.com/p/goauth2/oauth"
"code.google.com/p/google-api-go-client/content/v2"
)