Skip to content

Instantly share code, notes, and snippets.

View AlekSi's full-sized avatar
🕊️

Alexey Palazhchenko AlekSi

🕊️
View GitHub Profile
@AlekSi
AlekSi / new.go
Last active December 15, 2015 20:19 — forked from mitchellh/new.go
// This is a dead simple wrapper that can have setuid set on it so that
// the sudo helper is run as root. It is expected to run in the same CWD
// as the actual Ruby sudo helper. Any arguments to this script are forwarded
// to the Ruby sudo helper script.
package main
import (
"log"
"os"
"path/filepath"
@AlekSi
AlekSi / new.go
Created April 5, 2013 07:33 — forked from mitchellh/new.go
// This is a dead simple wrapper that can have setuid set on it so that
// the sudo helper is run as root. It is expected to run in the same CWD
// as the actual Ruby sudo helper. Any arguments to this script are forwarded
// to the Ruby sudo helper script.
package main
import (
"fmt"
"os"
"path/filepath"
// Test case for http://code.google.com/p/go/issues/detail?id=4191
package main
import (
"bytes"
"io"
"log"
"net/http"
"time"
)
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)();
};
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: #{$?}"