Skip to content

Instantly share code, notes, and snippets.

Avatar
🇰🇷

CHANN channprj

🇰🇷
View GitHub Profile
@ypereirareis
ypereirareis / docker_wait_hosts.sh
Last active Aug 19, 2016
Script to wait for a host to become available locally
View docker_wait_hosts.sh
wait_single_host() {
local host=$1
shift
local port=$1
shift
echo "==> Check host ${host}:${port}"
while ! nc ${host} ${port} > /dev/null 2>&1 < /dev/null; do echo " --> Waiting for ${host}:${port}" && sleep 1; done;
}
@fetep
fetep / genhttplogs.rb
Created Mar 14, 2012
apache log generator
View genhttplogs.rb
#!/usr/bin/ruby
class IPGenerator
public
def initialize(session_count, session_length)
@session_count = session_count
@session_length = session_length
@sessions = {}
end
@Nesffer
Nesffer / bot.js
Created Nov 3, 2016
Telegram Bot Shell
View bot.js
const shell = require('./modules/shell');
var shellRegex = new RegExp('^/shell(' + BOTNAME + ')?$', 'i');
bot.onText(shellRegex, (msg, match) => {
var messageId = msg.message_id;
var chatId = msg.chat.id;
var fromId = msg.from.id;
var opts = {
reply_markup: JSON.stringify({force_reply: true, selective: true}),
reply_to_message_id: messageId
@kimdwkimdw
kimdwkimdw / guide.md
Last active Jul 25, 2017
Python 2.x Encoding cheatsheet
View guide.md
@matthewriley
matthewriley / Git2130onRHEL7x.md
Created May 12, 2017
Install Git 2.13.0 from source on RHEL 7.x
View Git2130onRHEL7x.md

Install Git 2.13.0 from source on RHEL 7.x

These are the Terminal commands I recently used (June 2016) to install Git 2.13.0 from source on RHEL 7.x. I ran this in a VirtualBox VM after a fresh install from the ISO.

You mileage will vary as the yum packages are updated over time. The yum install line below should include all the dependencies, at least it did for me. Depending upon how often you use yum update you may need to run yum --enablerepo=base clean metadata as su before you run the following commands.

cd ~/Downloads
su
yum install autoconf cpio curl-devel expat-devel gcc gettext-devel make openssl-devel perl-ExtUtils-MakeMaker zlib-devel
wget -O v2.13.0.tar.gz https://github.com/git/git/archive/v2.13.0.tar.gz
@dahlia
dahlia / query_debug.py
Last active May 4, 2018
Print SQLAlchemy queries (including bind params).
View query_debug.py
"""Print SQLAlchemy queries (including bind params).
See also: http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html#faq-sql-expression-string
"""
def show_query(query):
qc = query.statement.compile(
dialect=query.session.bind.dialect,
@Sepero
Sepero / slash_middleware.py
Created Mar 26, 2012 — forked from gregplaysguitar/slash_middleware.py
Remove slashs in django - like APPEND_SLASH but opposite.
View slash_middleware.py
""" Author contact: sepero 111 @ gmail . com """
from django import http
from django.utils.http import urlquote
from django.core import urlresolvers
class RemoveSlashMiddleware(object):
"""
This middleware works like django's built in APPEND_SLASH, but in reverse. Eg
@blainerothrock
blainerothrock / gen.swift
Last active Jul 12, 2018
A Very Simple Genetic Algorithm Written in Swift 3
View gen.swift
#!/usr/bin/env xcrun swift -O
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many
View update_pip_list.py
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
@LucaTNT
LucaTNT / iTunes-now-playing-on-TouchBar.scpt
Last active Sep 27, 2018
his script can be used in conjunction with Better Touch Tool to display the currently playing track in iTunes on the MacBook Pro TouchBar. More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
View iTunes-now-playing-on-TouchBar.scpt
-- This script can be used in conjunction with Better Touch Tool to display the currently playing track on the MacBook Pro TouchBar
-- More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar
if application "iTunes" is running then
tell application "iTunes"
if player state is playing then
return (get artist of current track) & " - " & (get name of current track)
else
return ""
end if