Skip to content

Instantly share code, notes, and snippets.

@Y4suyuki
Y4suyuki / print_anim.py
Created October 3, 2013 06:22
python script which print animation on console
import time
import sys
animation = "|/-\\"
for i in range(100):
time.sleep(0.1)
sys.stdout.write("\r" + animation[i % len(animation)])
sys.stdout.flush()
@Stanback
Stanback / nginx.conf
Last active March 30, 2025 03:57 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@glnds
glnds / less-cheatsheet.md
Last active June 27, 2025 11:04
Less Cheatsheet

Less Cheatsheet

less {filename}

Navigation
SPACE forward one window
b backward one window
d forward half window
@mardix
mardix / gist:38895305786610152efa
Created May 5, 2014 18:50
array_map is slower and more of memory hug than foreach in PHP
While I was working on a personal project, I decided to compare foreach vs array_map to iterate over a large set of items.
So to support my decision, I ran a benchmark on both foreach and array_map.
With a simple array of 1,000,000 objects, I iterate over them with foreach and array_map. And surprisingly, foreach ran in 0.24sec average, while array_map took over 3.30sec.
Also array_map ran out of memory, I had to do an ini_set("memory_limit","512M"); to at least get some results.
My system:
Macbook
@amatellanes
amatellanes / celery.sh
Last active April 28, 2025 03:31
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@synther
synther / gist:d376100a8bae896d0caf
Last active June 16, 2025 15:51
linux signals cheat sheet
Signal Value Action Comment
SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active June 18, 2025 17:13
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@artjomb
artjomb / infiniteScroll_1.py
Last active June 12, 2023 00:00
infinite scroll of stackstatus with python in phantomjs
import selenium
import time
from selenium import webdriver
browser = webdriver.PhantomJS("phantomjs")
browser.get("https://twitter.com/StackStatus")
print browser.title
pause = 3
@developius
developius / README.md
Last active May 20, 2025 11:20
Setup SSH keys for use with GitHub/GitLab/BitBucket etc
@rochacbruno
rochacbruno / mainpython.md
Last active July 22, 2024 19:03
Use of __main__.py

The use of __main__.py to create executables

myprojectfolder/
    |_ __main__.py
    |_ __init__.py

Being __main__.py:

print("Hello")