Skip to content

Instantly share code, notes, and snippets.

@yann2192
yann2192 / genpass.py
Created July 23, 2013 09:55
Python script to gen password
import sys, random, string
myrg = random.SystemRandom()
if len(sys.argv) > 1:
length = int(sys.argv[1])
else:
length = 30
alphabet = "".join((string.letters, string.digits, string.punctuation))
pw = "".join(myrg.choice(alphabet) for _ in range(length))
print pw
@yann2192
yann2192 / go.snippets
Last active December 19, 2015 19:49
.vim/snippets/
snippet import
import (
${1}
)
snippet const
const (
${1}
)
snippet err
if err != nil {
@yann2192
yann2192 / vimrc
Last active September 11, 2021 01:30
set shell=/bin/bash
if $TERM == "xterm"
set t_Co=256 " 256 colors
endif
set nocompatible " be iMproved
let mapleader="," " change the leader to be a comma vs slash
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Modify by linuz.ly
package main
import (
"bytes"
"fmt"
"code.google.com/p/go.crypto/ssh"
@yann2192
yann2192 / gist:4144475
Created November 25, 2012 17:34
Find a file in subdir
import os
def findInSubdirectory(filename, subdirectory=''):
if subdirectory:
path = subdirectory
else:
path = os.getcwd()
for root, dirs, names in os.walk(path):
if filename in names:
return os.path.join(root, filename)
@yann2192
yann2192 / long_polling.go
Created November 2, 2012 16:01 — forked from border/long_polling.go
long polling for golang
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@yann2192
yann2192 / redcon.go
Created October 31, 2012 16:21 — forked from elazarl/redcon.go
redirect network stream
package main
import (
"log"
"io"
"os"
"crypto/tls"
"strings"
"net"
"flag"
@yann2192
yann2192 / fabfile.py
Created October 24, 2012 14:19 — forked from justinvoss/fabfile.py
Example Fabric and Cuisine Scrips
from deployment.cuisine import *
from fabric.api import *
from fabric.context_managers import *
from fabric.utils import puts
from fabric.colors import red, green
import simplejson
import os
@yann2192
yann2192 / mydjangoorm.py
Created October 23, 2012 07:43
Revert database to django models
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import random
from django.conf import settings
from django.core.management import setup_environ
s = {
"DATABASE_ENGINE": "django.db.backends.postgresql_psycopg2",
@yann2192
yann2192 / geventreactor.py
Created August 19, 2012 12:50 — forked from juanriaza/geventreactor.py
Twisted reactor running on gevent (libevent+greenlet)
## Copyright (C) 2011 by Jiang Yio <http://inportb.com/>
## Please find instructions at <http://wiki.inportb.com/python:geventreactor>
## The latest code is available at <https://gist.github.com/848058>
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions: