Skip to content

Instantly share code, notes, and snippets.

View nilportugues's full-sized avatar

Nil Portugués Calderó nilportugues

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

@nilportugues
nilportugues / DetectAdBlock.js
Created May 14, 2018 16:10 — forked from hotdang-ca/DetectAdBlock.js
Detect AdBlockers from a React Component
/**
*
* Detect Ad Blockers
*
* Copyright (c) 2017 James Robert Perih
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
# to cut first 3 seconds and length 8 seconds (custom step done for each file)
ffmpeg -ss 3 -t 8 -i VID00080.MP4 -vcodec copy -acodec copy white.MP4
# to burn in the timecode (r=framerate) (use in loop like below)
# ffmpeg -i $MOVIE -vf "drawtext=fontfile=/Users/artsyinc/Library/Fonts/PxPlus_VGA_SquarePx.ttf: fontsize=128: timecode='00\:00\:00\:00': r=30: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" timecode/$MOVIE
# to speed up
for MOVIE in $(ls | grep MP4);
do LENGTH=$(ffprobe -i $MOVIE -show_format -loglevel quiet | egrep -oE 'duration=(\d+)' | awk -F= '{print $2}');
RATIO=$(echo 7.0/$LENGTH | bc -l);
@nilportugues
nilportugues / docker-cleanup-resources.md
Created November 15, 2017 16:59 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@nilportugues
nilportugues / KongJwt.md
Created June 5, 2017 21:57 — forked from martinheld/KongJwt.md
Short example to use JWT with Kong

JWT Kong Example

  • Get and Start Kong and Co
git clone [email protected]:Mashape/docker-kong.git
cd docker-kong/compose
docker-compose up
  • Create Kong API Route
#!/bin/python
# -*- coding: utf-8 -*-
from time import sleep
from random import randint
from selenium import webdriver
from pyvirtualdisplay import Display
class MuncherySpider():
@nilportugues
nilportugues / using-rxjs-instead-of-flux-with-react.md
Created March 18, 2016 01:15 — forked from justinwoo/using-rxjs-instead-of-flux-with-react.md
Using RxJS instead of Flux with React to organize data flow

Reposted from Qiita

For almost a year now, I've been using this "flux" architecture to organize my React applications and to work on other people's projects, and its popularity has grown quite a lot, to the point where it shows up on job listings for React and a lot of people get confused about what it is.

Why I'm tired of using and teaching flux

There are a billion explainations on the internet, so I'll skip explaining the parts. Instead, let's cut to the chase -- the main parts I hate about flux are the Dispatcher and the Store's own updating mechanism.

If you use a setup similar to the examples in facebook/flux, and you use flux.Dispatcher, you probably have this kind of flow:

@nilportugues
nilportugues / GlobalMercator.php
Created February 2, 2016 10:15 — forked from ramunasd/GlobalMercator.php
GlobalMercator.php provides support for converting between latitude and longitude coordinates and a “quadtree” representation that makes it easy to search a database for physically close points.
<?php
/*
GlobalMercator - part of Aggregate Map Tools
Version 1.0
Copyright (c) 2009 The Bivings Group
All rights reserved.
Author: John Bafford
http://www.bivings.com/
http://bafford.com/softare/aggregate-map-tools/
@nilportugues
nilportugues / mysql2sqlite.sh
Created December 25, 2015 21:09 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@nilportugues
nilportugues / README.md
Created November 4, 2015 20:35 — forked from smoya/README.md
Get php trace -on segmentation fault- using xdebug
  • Enable the tracer on your xdebug.ini file (see the xdebug.ini file).
  • If you are gonna trace an http request, make sure your xdebug.trace_output_dir is writable by the webserver user (www-data).
  • Execute your script or your request. You can use produce_segmentation.php to test.
  • See the trace file(s) on your xdebug.trace_output_dir.