Skip to content

Instantly share code, notes, and snippets.

View azhtom's full-sized avatar
🏠
Working from home

Daniel Soria azhtom

🏠
Working from home
View GitHub Profile
@azhtom
azhtom / bm.py
Last active December 7, 2018 03:59
Boyer Moore implementation in Python
def fn(pattrn, table, text, _range):
x = 0
if _range[1] <= len(text):
x = 1
for i in range(_range[0], _range[1]):
if text[_range[1] - x] != pattrn[len(pattrn) - x]:
_ch = text[_range[1] - x]
r = [x for x in table if x[1] == _ch]
_shift = len(pattrn) if not r else r[0][0]
_shift = _range[1] + (_shift + 1 if _shift < 1 else _shift)
@azhtom
azhtom / gist:8b0169a97f96872485f0
Last active August 29, 2015 14:15
(NGINX) NON-WWW TO WWW
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
}
@azhtom
azhtom / apache2.conf
Created December 16, 2014 20:57
Apache Reverse Proxy (Django Project)
<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot /var/www
ProxyRequests Off
ProxyPass /media !
ProxyPass /static !
ProxyPass / http://127.0.0.1:8000/
@azhtom
azhtom / gist:6afc4448887d379f2764
Created November 25, 2014 21:28
Sublime Text command line SUBL
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
@azhtom
azhtom / hexlist
Created September 14, 2014 16:40
Hex Opacity Values
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
mysql -uroot -p --default-character-set=utf8 database < dump.sql
@azhtom
azhtom / merge
Created May 12, 2014 17:25
Merge Two objetcs c#
public void CopyValues<T>(T target, T source)
{
Type t = typeof(T);
var properties = t.GetProperties().Where(prop => prop.CanRead && prop.CanWrite);
foreach (var prop in properties)
{
var value = prop.GetValue(source, null);
if (value != null)
@azhtom
azhtom / timeout
Created March 5, 2014 15:57
TimeOut in Android
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
Log.i("tag", "This'll run 300 milliseconds later");
}
}, 300);
@azhtom
azhtom / newuser
Created February 11, 2014 16:45
Create a new user admin in ActiveAdmin
AdminUser.create!(:email => '[email protected]', :password => 'password', :password_confirmation => 'password')
@azhtom
azhtom / gist:8830915
Created February 5, 2014 19:12
[LINUX] Find PID
ps -ef | awk '/[k]eyword/{print $2}'