Skip to content

Instantly share code, notes, and snippets.

View hasantayyar's full-sized avatar
⌨️
AFK

Hasan Tayyar Beşik hasantayyar

⌨️
AFK
View GitHub Profile
# inspired by https://github.com/ptrofimov/tinyredisclient
require 'socket'
class TinyRedisClient
RN = "\r\n"
def initialize(host='localhost', port=6379)
@socket = TCPSocket.new(host, port)
end
#!/usr/bin/env bash
# Things to do after install Ubuntu 11.4 (Natty)
# Enabled partner repo
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
STOP="deb "
REPO="partner"
sudo sed -i "/^# $STOP.*$REPO/ s/^# //" /etc/apt/sources.list
# Repos
@hasantayyar
hasantayyar / hhvm_magento_setup.md
Last active August 29, 2015 14:26 — forked from tegansnyder/hhvm_magento_setup.md
HHVM Magento Server Setup

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
@hasantayyar
hasantayyar / rate_limit.js
Created September 23, 2015 19:52 — forked from mattheworiordan/rate_limit.js
Rate limiting function calls with JavaScript and Underscore.js
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@hasantayyar
hasantayyar / web-servers.md
Created November 12, 2015 14:36 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
function PeerConnectionImpl(originId,targetId,initiator,reliability){
this.reliable = reliability;
this.originId = originId;
this.targetId = targetId;
//you can use adapter.js instead
if (window.webkitRTCPeerConnection) {
this.RTCPeerConnection = webkitRTCPeerConnection;
this.RTCSessionDescription = RTCSessionDescription;
} else if (window.mozRTCPeerConnection) {
//delete turn servers due to incompatablitiy now
@hasantayyar
hasantayyar / GIF-Screencast-OSX.md
Created March 27, 2016 09:21 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""
@hasantayyar
hasantayyar / get-social-shares
Created May 16, 2016 14:11 — forked from ihorvorotnov/get-social-shares
Get number of shares from social platforms
Facebook*:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
+ works, returns shares, likes, comments and total
Twitter:
http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
+ v1 API but still works
Reddit:
http://buttons.reddit.com/button_info.json?url=%%URL%%