Skip to content

Instantly share code, notes, and snippets.

View iRhonin's full-sized avatar
🌱

Arash Fatahzade iRhonin

🌱
  • Nobitex
View GitHub Profile
@ibeex
ibeex / foo.log
Created August 4, 2012 13:46
Flask logging example
A warning occurred (42 apples)
An error occurred
@cincodenada
cincodenada / rot.py
Created September 14, 2013 00:09
Quick binary rotation (rotl/rotr) in Python
def rotl(num, bits):
bit = num & (1 << (bits-1))
num <<= 1
if(bit):
num |= 1
num &= (2**bits-1)
return num
def rotr(num, bits):
@rxaviers
rxaviers / gist:7360908
Last active June 29, 2024 18:36
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@zekefast
zekefast / move_postgres_data_to_ram.bash
Last active September 26, 2023 14:37
Move Postgres data_directory to RAM to improve IO speed and test performance. Run as root/sudo.
#!/bin/bash
# It is probably redundant if you set settings mentioned in https://gist.github.com/zekefast/42273658939724ba7c7a .
# But anyway it will not hurt anybody (sure if you are not putting your production database to RAM :)).
#
# Look for more detailed description in follow articles:
# - http://blog.vergiss-blackjack.de/2011/02/run-postgresql-in-a-ram-disk/
#
# ATTENTION:
# DO NOT apply this approach if you store important data in postgresql cluster, because that could cause
@pylover
pylover / inspections.txt
Last active April 22, 2024 07:47 — forked from ar45/inspections.txt
PyCharm inspections
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'
# noinspection PyPep8
# noinspection PyPep8Naming
# noinspection PyTypeChecker
# noinspection PyAbstractClass
# noinspection PyArgumentEqualDefault
# noinspection PyArgumentList
# noinspection PyAssignmentToLoopOrWithParameter
# noinspection PyAttributeOutsideInit
@zealot128
zealot128 / crontab.cron
Created October 18, 2016 20:42
Omnibus Gitlab backup cronjob
# Crontab
# once per week backup, move to "/backup" gzip it, delete everything but the latest 5 files
0 4 * * 1 /opt/gitlab/bin/gitlab-ci-rake gitlab:backup:create CRON=1 && mv /var/opt/gitlab/backups/* /backup/ && cd /backup && gzip *.tar && rm `ls -t | awk 'NR>5'`
@BlueNexus
BlueNexus / python2pseudo.py
Last active May 10, 2024 11:05
Python to Pseudocode converter
import os.path
import re
'''
INSTRUCTIONS
1. Create a file with the following code
2. Put the file you want to convert into the same folder as it, and rename it to "py_file.py"
3. Add a "#F" comment to any lines in the code which have a function call that doesn't assign anything (so no =),
as the program cannot handle these convincingly
4. Run the converter file
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active June 28, 2024 14:47 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@g105b
g105b / curlpool.sh
Last active March 11, 2024 06:17
Pool 100 parallel curl requests at a time
#!/bin/bash
target=${1:-http://example.com}
while true # loop forever, until ctrl+c pressed.
do
for i in $(seq 100) # perfrom the inner command 100 times.
do
curl $target > /dev/null & # send out a curl request, the & indicates not to wait for the response.
done
wait # after 100 requests are sent out, wait for their processes to finish before the next iteration.