Skip to content

Instantly share code, notes, and snippets.

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

Mazarin djaiss

👋
Maker of open source web softwares.
View GitHub Profile
@djaiss
djaiss / timezone.php
Last active March 25, 2023 01:43
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 / 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 / gist:a55d5b9df87aa1892f6a
Created April 7, 2015 13:08
Get hostname on the current machine
# Wait for it
`hostname`
Done.
# 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: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
@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

Notes

This is the latest version of an email which I send periodically, offering customers the opportunity to pre-pay for SaaS in return for a discount. The benefits to the SaaS company are better cash flow and reduced churn rate. The benefits to the customer are, well, in the email. This genre of email has produced hundreds of thousands of dollars in pre-pays for some companies I work with, and it rarely requires any more work than this example.

I've put $79 is as a placeholder for the cost of the user's plan. We calculate that for each account, naturally, along with the billing contact's name.

Subject: Save $79 on Appointment Reminder (and get a tax write-off) Formatting: 100% plain text. Gmail automatically links up the central link. From: Patrick McKenzie (Appointment Reminder) patrick@appointmentreminder.org

# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@djaiss
djaiss / gist:9514127
Last active August 29, 2015 13:57
VIM ⌘+A
To put in your .vimrc:
nmap <leader>a gg<CR>^<CR>V<CR>G<CR>$<cr>
@djaiss
djaiss / gist:4623525
Created January 24, 2013 15:51
Add colors to your `git log`, `git status` and everything git.
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold