Skip to content

Instantly share code, notes, and snippets.

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

Jean-Pierre Pommet jppommet

🏠
Working from home
View GitHub Profile

It seems that it does not matter what timezone is on the server as long as you have the time set right for the current timezone, know the timezone of the datetime columns that you store, and are aware of the issues with daylight savings time.

On the other hand if you have control of the timezones of the servers you work with then you can have everything set to UTC internally and never worry about timezones and DST.

Here are some notes I collected of how to work with timezones as a form of cheatsheet for myself and others which might influence what timezone the person will choose for his/her server and how he/she will store date and time.

MySQL Timezone Cheatsheet

@jppommet
jppommet / bcm4352-wifi-ac.md
Created July 4, 2014 20:03
Linux Ubuntu Drivers for Broadcom Chipset BCM4352 802.11ac Wireless Network Adapter [14e4:43b1]
@jppommet
jppommet / int2ip.js
Last active December 26, 2023 13:44
javascript conversion from ip address to long integer and vice versa
function int2ip (ipInt) {
return ( (ipInt>>>24) +'.' + (ipInt>>16 & 255) +'.' + (ipInt>>8 & 255) +'.' + (ipInt & 255) );
}
@jppommet
jppommet / unix-commands.md
Created March 6, 2014 22:17
A list of unix commands
  • column: create columns from text input
  • tr: translate/substitute/delete input
  • join: like a database join but for text
  • comm: file comparison like a db join
  • paste: put lines in a file next to each other
  • rs: reshape arrays
  • jot: generate data
  • expand: replace spaces and/or tabs
  • time: track time and resourcing
  • watch: execute something on a schedule in realtime
@jppommet
jppommet / app.py
Created June 7, 2016 20:32
youtube-dl wrapper for AWS Lambda
from __future__ import unicode_literals
from youtube_dl import YoutubeDL
import boto3
import os
class Logger(object):
def debug(self, msg):
pass
@jppommet
jppommet / nodejs-crypto-sha1.js
Last active February 17, 2022 16:05
nodejs crypto sha1 hash in hexadecimal string representation.
// We use crypto.randomBytes(20) as an example to generate the seed with a higher entropy, higher number of unique values
var hash = crypto.createHash('sha1').update(crypto.randomBytes(20)).digest('hex')
@jppommet
jppommet / sidekiq_delete_jobs.md
Created August 26, 2021 03:32 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs

How to delete Sidekiq jobs in a Rails app using ActiveJobs

Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
@jppommet
jppommet / alias_matchers.md
Created September 14, 2017 21:28 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@jppommet
jppommet / pre-commit.sh
Created August 3, 2017 23:41
git pre-commit hook rubocop ruby modified/staged files
#!/bin/sh
#TODO: add exclude <file>.rb in rubocop.yml ?
git status --porcelain | egrep "^(A|AM|^M).+\.rb$" | awk '{print $NF}' | xargs rubocop -a