Skip to content

Instantly share code, notes, and snippets.

View zkan's full-sized avatar
🐻
Stay Hungry. Stay Foolish.

Kan Ouivirach zkan

🐻
Stay Hungry. Stay Foolish.
View GitHub Profile
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@zkan
zkan / fizzbuzz.py
Last active August 29, 2015 14:25 — forked from kowito/fizzbuzz.py
#!/usr/bin/env python
import unittest
import sys
class FizzBuzz:
def fizz(self, i):
try:
0 / (i % 3)
return self.buzz(i)
except ZeroDivisionError:
@zkan
zkan / replaceText.js
Last active August 29, 2015 14:27 — forked from freshsnippets/replaceText.js
JavaScript: jQuery replaceText
jQuery.fn.replaceText = function( search, replace, text_only ) {
return this.each(function(){
var node = this.firstChild,
val,
new_val,
remove = [];
if ( node ) {
do {
if ( node.nodeType === 3 ) {
val = node.nodeValue;
@zkan
zkan / django_haystack_testing
Created October 21, 2015 12:50 — forked from bwreilly/django_haystack_testing
testing search in django (haystack)
TEST_INDEX = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'TIMEOUT': 60 * 10,
'INDEX_NAME': 'test_index',
},
}
@zkan
zkan / tmux-cheatsheet.markdown
Created November 29, 2015 05:41 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zkan
zkan / letsencrypt-auto-renew
Created January 3, 2016 07:24 — forked from neutronth/letsencrypt-auto-renew
Let's Encrypt auto renew script
#/bin/sh
OPTS=$(getopt -o cehw: --long config:,expire-limit:,help,webservice: -n "$0" -- "$@")
if [ $? != 0 ]; then
echo "Terminating ..." >&2
exit 1
fi
CONFIG=/etc/letsencrypt/cli.ini
WEBSERVICE=nginx
@zkan
zkan / q.py
Created April 20, 2016 01:43 — forked from fheisler/q.py
Q-learning Tic-tac-toe
import random
class TicTacToe:
def __init__(self, playerX, playerO):
self.board = [' ']*9
self.playerX, self.playerO = playerX, playerO
self.playerX_turn = random.choice([True, False])
def play_game(self):
#!/bin/sh
# The script updates the Wordpress.org SVN repository after pushing
# the latest release from Github
# Credit: https://guh.me/how-to-publish-a-wordpress-plugin-from-github
# Semantic Versioning: http://semver.org/
BASE_DIR=`pwd`
TMP_DIR=$BASE_DIR/tmp
@zkan
zkan / countries.json
Created June 19, 2016 14:04 — forked from keeguon/countries.json
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@zkan
zkan / active.md
Created August 3, 2016 14:00 — forked from statguy/active.md

Most active GitHub users in Thailand

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 29 Jul 2015 01:52:41 GMT till Fri, 29 Jul 2016 01:52:41 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user => user.followers > 6)