Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import os
import sys
import time
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
def when_file_changed(filename):
"""
@ibotdotout
ibotdotout / fizzubzz.py
Last active August 29, 2015 14:24
FizzBizz Nested If
x = 105
if x%7 == 0 and x%3 == 0 and x%5 == 0:
print("FizzBuzzBang")
elif x%7 == 0 and x%5 == 0:
print("BuzzBang")
elif x%7 == 0 and x%3 == 0:
print("FizzBang")
elif x%3 == 0 and x%5 == 0:
print("FizzBuzz")
@ibotdotout
ibotdotout / fizzbuzz_ocp.py
Last active April 5, 2020 05:26
FizzBuzz with Open/closed principle
#Kata with Up1 - Agile Thailand 2014 @ Eng CU
#Sat 7 June 2014
class FizzBuzzFactory():
def create(self):
rules = [FizzBuzzBangRule(), BuzzBangRule(), FizzBangRule(), FizzBuzzRule(),
BangRule, BuzzRule(),FizzRule(),NormalRule()]
return FizzBuzz(rules)
class FizzBuzz():
@@ -55,7 +55,21 @@
After login, make `client` and `client_in` instance
to communicate with LINE server
"""
- raise Exception("Code is removed because of the request of LINE corporation")
+
+ self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
+ self.transport_in = THttpClient.THttpClient(self.LINE_HTTP_IN_URL)
+
+ self.transport.setCustomHeaders(self._headers)
# original: https://github.com/carpedm20/LINE/blob/master/examples/echobot.py
from line import LineClient, LineGroup, LineContact
try:
client = LineClient("ID", "PASSWORD")
print client.authToken #print authToken before error and use this login again
#client = LineClient(authToken="AUTHTOKEN")
except:
print "Login Failed"
@ibotdotout
ibotdotout / Line.Dockerfile
Last active August 29, 2015 14:26
Line Dockerfile - python2 on ubuntu
FROM dockerfile/python
RUN apt-get update -y && apt-get dist-upgrade -y
# Apache Thrift for line support
# http://www.saltycrane.com/blog/2011/06/install-thrift-ubuntu-1010-maverick/
RUN apt-get install -y automake libtool flex bison pkg-config g++ libssl-dev make libqt4-dev git \
debhelper cmake
RUN cd /tmp && curl http://archive.apache.org/dist/thrift/0.9.1/thrift-0.9.1.tar.gz | tar zx
@ibotdotout
ibotdotout / line_send_msg_by_user_id.py
Last active August 29, 2015 14:26
send line message by using line ID
from line import LineClient, LineGroup, LineContact
try:
client = LineClient("ID", "PASSWORD")
print client.authToken #print authToken before error and use this login again
#client = LineClient(authToken="AUTHTOKEN")
except:
print "Login Failed"
lineID = "Enter target LineID"
@ibotdotout
ibotdotout / .travis.yml
Created August 24, 2015 09:08
travis with docker
sudo: required
language: python
services:
- docker
before_install:
- docker build -t robot-packtpub .
@ibotdotout
ibotdotout / .travis.yml
Created August 24, 2015 09:09
travis with python and other services
language: python
python:
- "2.7"
services:
- mongodb
install:
- pip install -r requirements.txt
@ibotdotout
ibotdotout / robot-packtpub.txt
Last active July 22, 2016 11:10
Robotframework script to claim free packtpub book
*** Settings ***
Library Selenium2Library
*** Variables ***
${USER} [email protected]
${PASSWORD} password
${BROWSER} phantomjs
${HOME URL} https://www.packtpub.com/packt/offers/free-learning