Skip to content

Instantly share code, notes, and snippets.

View rezkam's full-sized avatar
🏠
Working from home

Rez rezkam

🏠
Working from home
View GitHub Profile
@dAnjou
dAnjou / flask-upload
Created June 5, 2012 12:35
Flask upload example
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
@nf
nf / hello-node.js
Created July 6, 2012 21:14
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

import socket
class ImageDownloadFailure(Exception):
def __init__(self, host, port, path, error):
self.host = host
self.port = port
self.path = path
msg = ('Failed to download %(path)s from %(host)s:%(port)s: %(error)s'
% {'host': host, 'port': port, 'path': path, 'error': error})
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active June 10, 2024 15:37
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@Bersam
Bersam / ofest-ir.js
Last active August 29, 2015 14:01
How to force register after registering was closed in #Ofest
// var content= content1_value +'<br>'+ content3_value + '<br>' + content4_value + '<br>' + content5_value + '<br>' + content6_value ;
var content= "VIP Person"
var email="me@example.com"
var name="DJ Hossein Fasanghari"
$.post("http://ofest.ir/site/registerorder", { 'name': name , 'email': email , 'content': content }, function (data) {
console.log("Done");
});
~/.cow/rc =>
listen = http://0.0.0.0:7070 # <-- Multiple line is allowed for multiple port
#logFile =
#alwaysProxy = true <- if you want to pass always over the proxy
loadBalance = backup/latency # <-- Choose backup or latency
# One is enaugh, but cow can do load balance :) ==> Start parent proxy list
proxy = ss://<enc-method>:<password>@<host>:<port> #<-- shadowsocks server
proxy = http://user:password@host:port # <--http(s) server
@rezkam
rezkam / Itmard_git_alias.sh
Last active June 1, 2022 07:09
New git alias set of ITMARD
#itmard git alias v0.4
alias gis='git status'
alias gil='git log'
alias gull='git pull origin '
alias gica='git commit -a -m '
alias gush='git push origin '
alias granch='git branch '
alias gich='git checkout '
alias gif='git diff'
alias gifa='git fetch --all'
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())