Skip to content

Instantly share code, notes, and snippets.

View djaiss's full-sized avatar
👋
Maker of open source web softwares.

Regis Freyd djaiss

👋
Maker of open source web softwares.
View GitHub Profile
@djaiss
djaiss / gist:e14b8b70dcb89c6e016b
Created January 4, 2015 18:22
Differences between dates from the command line
require 'date'
t = Time.now
endDate = Date.new(t.year, t.month, t.day)
startDate = Date.new(2011, 11, 22)
days = endDate - startDate
puts days.to_i
@djaiss
djaiss / gist:24d5542ffbeeb9f30c70
Created January 4, 2015 18:29
Password generator command line
# stolen from http://invert.svbtle.com/using-vim-as-a-password-manager
import random
f = open('/usr/share/dict/words')
words = map(lambda x: x.strip(), f.readlines())
password = '-'.join(random.choice(words) for i in range(2)).capitalize()
password += str(random.randint(1, 9999))
print password
# Manually secure port 6379
sudo iptables -A INPUT -p tcp --dport 6379 -s xxx.xxx.xxx.xxx -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 6379 -j DROP
sudo iptables -L
# Save current firewall config
sudo iptables-save > /etc/iptables.conf
# Load iptables.conf on startup
sudo nano /etc/rc.local
@djaiss
djaiss / gist:a55d5b9df87aa1892f6a
Created April 7, 2015 13:08
Get hostname on the current machine
# Wait for it
`hostname`
Done.
@djaiss
djaiss / gist:16b58f5781978d1ae2f5
Created June 17, 2015 22:52
HOW TO NOTIFY SEARCH ENGINES WHEN YOU POST TO JEKYLL
# Credit / Stolen from http://natelandau.com/how-to-notify-services-when-post-jekyll/
# Ping Pingomatic
desc 'Ping pingomatic'
task :pingomatic do
begin
require 'xmlrpc/client'
puts '* Pinging ping-o-matic'
XMLRPC::Client.new('rpc.pingomatic.com', '/').call('weblogUpdates.extendedPing', 'YOURSITE.com' , 'http://YOURSITE.com', 'http://YOURSITE.com/atom.xml')
rescue LoadError
@djaiss
djaiss / timezone.php
Last active June 6, 2025 16:15
Timezone in PHP
<?php
return array (
'(UTC-11:00) Midway Island' => 'Pacific/Midway',
'(UTC-11:00) Samoa' => 'Pacific/Samoa',
'(UTC-10:00) Hawaii' => 'Pacific/Honolulu',
'(UTC-09:00) Alaska' => 'US/Alaska',
'(UTC-08:00) Pacific Time (US &amp; Canada)' => 'America/Los_Angeles',
'(UTC-08:00) Tijuana' => 'America/Tijuana',
'(UTC-07:00) Arizona' => 'US/Arizona',
@djaiss
djaiss / db_size.sql
Last active August 29, 2015 14:28
Calculate the size of your Mysql DB
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema ;
@djaiss
djaiss / table.css
Created November 30, 2015 23:56 — forked from colintoh/table.css
Table CSS
table { display: table }
tr { display: table-row }
thead { display: table-header-group }
tbody { display: table-row-group }
tfoot { display: table-footer-group }
col { display: table-column }
colgroup { display: table-column-group }
td, th { display: table-cell }
caption { display: table-caption }
@djaiss
djaiss / gist:85a0ada83e6bca68e41e
Last active September 30, 2025 06:54
Block Twitter/Facebook in your /etc/hosts
# Block Facebook IPv4
127.0.0.1 www.facebook.com
127.0.0.1 facebook.com
127.0.0.1 login.facebook.com
127.0.0.1 www.login.facebook.com
127.0.0.1 fbcdn.net
127.0.0.1 www.fbcdn.net
127.0.0.1 fbcdn.com
127.0.0.1 www.fbcdn.com
127.0.0.1 static.ak.fbcdn.net
<!-- The icons of the countries are provided by https://github.com/djaiss/mapsicon, available under a `do what you want with it` license. -->