Skip to content

Instantly share code, notes, and snippets.

View mystix's full-sized avatar

Marc mystix

  • Singapore
View GitHub Profile
@mystix
mystix / mysql2-mojave.md
Created April 15, 2019 06:50 — forked from fernandoaleman/mysql2-mojave.md
Install mysql2 on MacOS Mojave

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@mystix
mystix / countdown.sh
Last active January 23, 2019 01:26 — forked from krohne/countdown.sh
Countdown timer in bash shell script
#!/bin/bash
# $1 = # of seconds
# $@ = What to print after "Waiting n seconds"
countdown() {
secs=$1
shift
msg=$@
while [ $secs -gt 0 ]
do
printf "\r\033[KWaiting %.d seconds $msg" $((secs--))
@mystix
mystix / cron.sh
Created March 31, 2018 04:50
[OSX] Cron + zsh + rbenv
*/15 * * * * $(which zsh) -lc 'export PATH=/usr/local/bin:/usr/local/sbin:$PATH; eval "$(rbenv init -)"; ruby SOME_SCRIPT.rb'
@mystix
mystix / download-portable-apps.ps1
Last active February 7, 2018 17:11
Powershell: Download Portable Apps Platform to Desktop
# adapted from https://blog.jourdant.me/post/3-ways-to-download-files-with-powershell
$version = "14.4.3"
$url = "http://download3.portableapps.com/portableapps/pacplatform/PortableApps.com_Platform_Setup_$version.paf.exe"
$output = "$home\Desktop\paf.exe"
Import-Module BitsTransfer
Start-BitsTransfer -Source $url -Destination $output
@mystix
mystix / RDS_INSTALL.bat
Last active June 19, 2023 01:42 — forked from anthonyeden/RDS_INSTALL.bat
Let's Encrypt & Microsoft Remote Desktop (Windows Server 2016) - Installation Script
@echo off
"C:\Program Files\letsencrypt-win-simple\letsencrypt.exe" --renew --baseuri "https://acme-v01.api.letsencrypt.org/"
REM run powershell script, bypassing security warnings for 3rd-party script
powershell -ExecutionPolicy bypass -File "C:\Program Files\letsencrypt-win-simple\RDS_INSTALL_CERT.ps1"
@mystix
mystix / encrypt_decrypt.rb
Created December 11, 2017 15:24 — forked from wteuber/encrypt_decrypt.rb
Simply encrypt and decrypt Strings in ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
end
{"date":"2016-02-12","deliveries":{"100197465":{"assign_to":"Azhar","delivery_time":"3pm - 6pm","postal_code":"576962","dispatched":true},"100197161":{"assign_to":"William","delivery_time":"9am - 12pm","postal_code":"150092","dispatched":true},"100197308":{"assign_to":"Azhar","delivery_time":"9am - 12pm","postal_code":"531984","dispatched":true},"100197033":{"assign_to":"William","delivery_time":"12pm - 3pm","postal_code":"138533","dispatched":true},"100197576":{"assign_to":"Steven","delivery_time":"3pm - 6pm","postal_code":"791447","dispatched":true},"100196820":{"assign_to":"Khoo","delivery_time":"6pm - 9pm","postal_code":"680682","dispatched":true},"100197198":{"assign_to":"Khoo","delivery_time":"9am - 12pm","postal_code":"680295","dispatched":true},"100197673":{"assign_to":"Azhar","delivery_time":"6pm - 9pm","postal_code":"760235","dispatched":true},"FL007456":{"assign_to":"William","delivery_time":"12pm - 3pm","postal_code":"","dispatched":true},"100197680":{"assign_to":"Hanapiah","delivery_time":"12pm -
@mystix
mystix / magento.conf
Created October 14, 2015 05:08 — forked from jonathonbyrdziak/magento.conf
A configuration file for magento under nginx.
#####################################################
#
# Provided by the Magento Support Center
# http://magentosupport.help/knowledgebase/configuring-nginx-to-work-with-magento-advanced/
#
# Your Magento Tutorial specialists
#
server {
listen *:8080;
server_name fanatik.redrokk.com www.fanatikbike.com fanatikbike.com;
@mystix
mystix / form.html
Last active September 9, 2015 13:48 — forked from gosseti/form.html
A credit card form using jQuery.payment
<form accept-charset="UTF-8" action="/payment" class="cardInfo" method="post">
<fieldset class="cardInfo__cardDetails">
<div class="form-row cardInfo__cc-num">
<label for="cc-num"><abbr title="required">*</abbr><span>Card Number</span></label>
<div class="cc-num__wrap">
<!-- using type="tel" because type="number" doesn’t pass HTML5 form validation with jQuery.payment formatting -->
<input id="cc-num" type="tel" class="paymentInput cc-num" placeholder="•••• •••• •••• ••••" autocompletetype="cc-number" required="required">
<span class="card" aria-hidden="true"></span>

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000