Skip to content

Instantly share code, notes, and snippets.

@evnpr
evnpr / StrategyPatterin.swift
Created December 23, 2016 03:51 — forked from omayib/StrategyPatterin.swift
an implementation of strategy pattern on swift
//: Playground - noun: a place where people can play
import UIKit
//lets to trya strategy pattern!
protocol QCallKit{
func dial()
func endCall()
func accept()
<?php
// this script was created by Akbar Taufiq Herlangga (Software Engineer at Qiscus)
// this script was created for the Qiscus TechTalk #35 - Build Your Own MVC Framework
//////////////////////////////////////////////////////////////////////
//////////////////////////// M O D E L ///////////////////////////////
@evnpr
evnpr / gist:5000947
Created February 21, 2013 00:27
poll function in server
def poll
last_post = params[:last_post]
def check
r = Post.all.order(:created_at => "ASC").last
if r.message != last_post
return true
else
return false
end
@evnpr
evnpr / gist:4656686
Created January 28, 2013 15:59
Facebook Hacker cup Qualifications round 1 question 1 2013
import re
f = open("1.in", "r")
N = int(f.readline())
a = 26
for i in range(N):
mydict = {}
total = 0
input = f.readline()
input = re.sub('[^A-Za-z0-9]+', '', input)
input = input.lower()
@evnpr
evnpr / gist:4263577
Created December 12, 2012 00:03
Direct Upload Amazon S3
<%
require 'base64'
require 'openssl'
require 'digest/sha1'
secret_key = "5J0VAOMMkrh5mYEJN4WuybZXfLFQMI"
policy_document = '{"expiration": "2013-01-01T00:00:00Z",
"conditions": [
{"bucket": "evanpurnama"},
@evnpr
evnpr / gist:4244006
Created December 9, 2012 09:13
candies
N = gets.to_i
a = [0]*(N)
for i in 0..(N-1) do
a[i] = gets.to_i
end
n = [1]*(N)
@evnpr
evnpr / post_file.php
Created October 11, 2012 00:30
To do a POST request by it self
function post_request($url, $data, $referer='') {
// Convert the data array into URL Parameters like a=b&foo=bar etc.
$data = http_build_query($data);
// parse the given URL
$url = parse_url($url);
if ($url['scheme'] != 'http') {
die('Error: Only HTTP request are supported !');
@evnpr
evnpr / ip.rb
Created October 11, 2012 00:24
To send ipconfig file every 30 seconds
tmd = 0
while 1
t = Time.now
tm = t.sec
if tm%30 == 0
tmo = tm
if tmd == 0
puts Time.now
file = File.open("iptime.txt","w")
file.write(Time.now)
@evnpr
evnpr / jinjalink_loader.py
Created June 12, 2012 00:25 — forked from Suor/jinjalink_loader.py
Jinja2 template loader for django