Skip to content

Instantly share code, notes, and snippets.

View laabroo's full-sized avatar

Ikhsyan Hasan laabroo

View GitHub Profile
/**
Nice trick to add floating view on bottom layout in UITableViewController
**/
import UIKit
class MyUITableViewController : UITableViewController {
fileprivate lazy var myFloatingView: UIView = {
let myView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: self.view.bounds.width, height: 80.0))
import UIKit
extention UIView {
func addConstrainWithFormat(format: String , views: UIView...){
var viewsDictionary = [String: UIView]()
for(index, view) in views.enumerated() {
let key = "v\(index)"
view.translatesAutoresizingMaskIntoConstraints = false
viewsDictionary[key] = view
@laabroo
laabroo / slug-text.js
Last active November 21, 2017 21:46
Make string as slug for url
function slugfy(text){
return text.toString().toLowerCase().trim()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/&/g, '-and-') // Replace & with 'and' change 'and' with your text like 'dan' for indonesian
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-');
}
//source : https://gist.github.com/mathewbyrne/1280286
@laabroo
laabroo / nginx.conf
Last active March 20, 2016 09:29
increase timeout
http {
##
#increase php timeout
##
fastcgi_read_timeout 300;
}
@laabroo
laabroo / php_timeout_increase
Created March 20, 2016 09:26
increase php timeout
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#kita tambahkan disini
fastcgi_read_timeout 300;
}
@laabroo
laabroo / craw_category.php
Last active March 18, 2016 16:32
Get Cookies from Goodreads.com and put it on each request
public function getUrl($genre, $page) {
$agents = array(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100508 SeaMonkey/2.0.4',
'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; da-dk) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11',
'Opera/9.25 (Windows NT 5.1; U; en)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
'Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Kubuntu)',
@laabroo
laabroo / hae.py
Last active March 10, 2016 10:52
Cange encoding to UTF-8 on Python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
laa = 'My Name'
broo = 'Laa BroÖntë'
@laabroo
laabroo / curl_get_asiandate.php
Last active February 11, 2016 23:24
Sample Request AsianDate
function curl_get_header($url = '', $user_agent = '', $headers = array()) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$result = curl_exec($ch);
curl_close($ch);
return $result;
@laabroo
laabroo / cara_instalasi_afftion
Last active August 29, 2015 14:17
Cara Instalasi Afftion
#PETUNJUK INSTALASI
===================
Update config di app/storage/config/config.php
Petunjuk pengisian:
> untuk penggunaan themes SINGLE STORE
* 'indexreq' diisi men atau women atau kids atau home
#!/bin/bash
#!/bin/sh
rpm -Uvh http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm &&
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel freetype-devel speex-devel -y &&
mkdir ~/ffmpeg_sources &&
cd ~/ffmpeg_sources &&
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz &&
tar xzvf yasm-1.3.0.tar.gz &&
cd yasm-1.3.0 &&
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" &&