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
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 19, 2024 13:30
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@ashkantaravati
ashkantaravati / UniversityProfRandScoreGen.js
Last active June 11, 2019 05:50
I was too lazy and tired to answer all the professor survey questions so I wrote this!
var matches = [].slice.call(document.querySelectorAll('[id^=DropDownList]'));//Gets all dropdown selectors in an array
for (var i=0;i<matches.length;i++){//iterate through dropdownlists
//** random number generator part
var min = Math.ceil(2);
var max = Math.floor(6);
var randscore=Math.floor(Math.random() * (max - min)) + min;
//** random number generator part ends
matches[i].selectedIndex=randscore.toString();// set scores
}//we're done
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@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.

@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'
~/.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
@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");
});
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active April 1, 2024 11:21
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

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})
@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.