Skip to content

Instantly share code, notes, and snippets.

View Darkborderman's full-sized avatar

Darkborderman Darkborderman

View GitHub Profile
@smoak
smoak / eventhooks
Created June 24, 2011 23:21
Event Hooks for python
class EventHook(object):
def __init__(self):
self.__handlers = []
def addHandler(self, handler):
self.__handlers.append(handler)
def removeHandler(self, handler):
self.__handlers.remove(handler)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@sp3c73r2038
sp3c73r2038 / app.py
Last active May 24, 2021 11:51
how to acccess multiple database with same tablename, in Flask and SQLAlchemy.
# -*- coding: utf-8 -*-
from flask import Flask
from sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+oursql://foo:bar@localhost/test1"
# binds multiple database definition
app.config['SQLALCHEMY_BINDS'] = {
"db1": "mysql+oursql://foo:bar@localhost/test1",
@edokeh
edokeh / index.js
Last active July 16, 2024 01:43
佛祖保佑,永无 BUG
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@TheWaWaR
TheWaWaR / flask_dump_request_response.py
Last active March 10, 2024 14:38
Flask dump request and response example
#!/usr/bin/env python
# coding: utf-8
import os
import sys
import json
import uuid
import tempfile
from flask import Flask, request, Response, g

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@heyalexej
heyalexej / pytz-time-zones.py
Created November 16, 2016 09:14
list of pytz time zones
>>> import pytz
>>>
>>> for tz in pytz.all_timezones:
... print tz
...
...
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
@bouassaba
bouassaba / override_git_tag.sh
Last active March 20, 2020 10:57
override git tag
# Delete the tag on any remote before you push
git push origin :refs/tags/<tagname>
# Replace the tag to reference the most recent commit
git tag -fa <tagname>
# Push the tag to the remote origin
git push origin master --tags
# source: http://stackoverflow.com/questions/8044583/how-can-i-move-a-tag-on-a-git-branch-to-a-different-commit
@dongjinleekr
dongjinleekr / consumer.sh
Last active March 25, 2024 03:00
Kafka benchmark commands
## Consumer Throughput: Single consumer thread, no compression
## Consumer Throughput: 3 consumer thread, no compression
bin/kafka-consumer-perf-test.sh --topic benchmark-3-3-none \
--zookeeper kafka-zk-1:2181,kafka-zk-2:2181,kafka-zk-3:2181 \
--messages 15000000 \
--threads 1