Skip to content

Instantly share code, notes, and snippets.

View AlekSi's full-sized avatar
🕊️

Alexey Palazhchenko AlekSi

🕊️
View GitHub Profile
package main
import (
"labix.org/v2/mgo"
"html/template"
"net/http"
"log"
"./signup"
)
@AlekSi
AlekSi / annoying.patch
Created January 19, 2013 14:28
Tiny patch for Go 1.0.3 to turn "is declared and not used" and "imported and not used" errors into warnings. See comment below.
diff -r 2d8bc3c94ecb src/cmd/gc/lex.c
--- a/src/cmd/gc/lex.c Fri Sep 21 17:10:44 2012 -0500
+++ b/src/cmd/gc/lex.c Sat Jan 19 18:25:39 2013 +0400
@@ -2200,7 +2200,7 @@
// errors if a conflicting top-level name is
// introduced by a different file.
if(!s->def->used && !nsyntaxerrors)
- yyerrorl(s->def->lineno, "imported and not used: \"%Z\"", s->def->pkg->path);
+ warnl(s->def->lineno, "imported and not used: \"%Z\"", s->def->pkg->path);
s->def = N;
(gdb) info locals
&id = 1073746000
(gdb) p id
No symbol "id" in current context.
in code:
id := C.struct_lala{v: 1}
@AlekSi
AlekSi / lib.h
Last active December 10, 2015 00:38
struct my {
void (*f)();
};
package main
import (
"encoding/json"
"math"
"time"
"github.com/labstack/echo"
"github.com/labstack/gommon/log"
)
def f1(s):
# Python 2: ok
# Python 3: TypeError: ord() expected string of length 1, but int found (it returns int for binary string)
# RPython : ok
return ord(s[0])
def f2(s):
# Python 2: ok
# Python 3: ok
# RPython : Blocked block -- operation cannot succeed: v1 = ord(v0)
[translation:ERROR] Error:
[translation:ERROR] Traceback (most recent call last):
[translation:ERROR] File "/Users/aleksi/Soft/pypy/pypy/translator/goal/translate.py", line 308, in main
[translation:ERROR] drv.proceed(goals)
[translation:ERROR] File "/Users/aleksi/Soft/pypy/pypy/translator/driver.py", line 791, in proceed
[translation:ERROR] return self._execute(goals, task_skip = self._maybe_skip())
[translation:ERROR] File "/Users/aleksi/Soft/pypy/pypy/translator/tool/taskengine.py", line 116, in _execute
[translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds)
[translation:ERROR] File "/Users/aleksi/Soft/pypy/pypy/translator/driver.py", line 285, in _do
[translation:ERROR] res = func()
@AlekSi
AlekSi / update.rb
Created August 21, 2011 15:20
Update all gems, packages, fetch all code, etc.
#! /usr/bin/env ruby
STDOUT.sync = true
STDERR.sync = true
def run(cmd, *ok_statuses)
puts "\n=========> #{cmd}"
system(cmd)
unless ([0] + ok_statuses).include?($?)
puts "Exit status: #{$?}"
@AlekSi
AlekSi / gist:1154108
Created August 18, 2011 13:53
MongoDB benchmark for Graylog2
count = 10000
size = 100 // megabytes
hosts = ['host1', 'host2', 'host3', 'host4', 'host5']
facilities = ['Server', 'Client', 'Proxy']
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz '.split('');
speed = 1500.0; // messages per second
start = new Date().getTime() - 24*60*60*1000;
puts "\n#{RUBY_ENGINE} #{RUBY_VERSION}:"
def run_tests
[
"now.strftime('%L')",
"now.strftime('%N')",
"now.strftime('%Q')",
"now.to_datetime.strftime('%L')",
"now.to_datetime.strftime('%N')",
"now.to_datetime.strftime('%Q')",