SELECT (date_trunc('MONTH', now()) + INTERVAL '1 MONTH - 1 day 23:59:59')::timestamp without time zone;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// twig/factory.js | |
'use strict'; | |
const Twig = require('twig'); | |
module.exports = function () { | |
Twig.extend(twig => { | |
function parseParams(state, params, context) { | |
if (params) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import collections | |
population = [1, 2, 3, 4] | |
weights = [0.5, 0.25, 0.15, 0.1] | |
samples = random.choices(population, weights, k=100) | |
print(collections.Counter(samples)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Optimize image image | |
* | |
* https://developers.google.com/speed/docs/insights/OptimizeImages | |
* -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB | |
* | |
* @access public | |
* @param string $filePath Path of the file | |
* @return string Raw image result from the process | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail | |
rep_url="https://github.com/nvm-sh/nvm.git" | |
last_tag=$( | |
git ls-remote --tags --quiet --exit-code --refs --sort version:refname "$rep_url" | \ | |
tail --lines 1 | \ | |
sed --regexp-extended 's@.+refs/tags/@@' | |
) | |
echo "$last_tag" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install Monaco font in Linux | |
# Version from nullvideo https://gist.github.com/rogerleite/99819#gistcomment-2799386 | |
sudo mkdir -p /usr/share/fonts/truetype/ttf-monaco && \ | |
sudo wget http://www.gringod.com/wp-upload/software/Fonts/Monaco_Linux.ttf -O - > \ | |
/usr/share/fonts/truetype/ttf-monaco/Monaco_Linux.ttf && \ | |
sudo fc-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shows local branches without remote | |
git branch -vv | cut -c 3- | awk '$3 !~/\[/ { print $1 }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user@host:/project-dir[master]$ git merge --no-ff DEV-999 | |
Auto-merging composer.lock | |
CONFLICT (content): Merge conflict in composer.lock | |
Automatic merge failed; fix conflicts and then commit the result. | |
user@host:/project-dir[master]$ git reset composer.lock | |
Unstaged changes after reset: | |
M composer.lock | |
user@host:/project-dir[master]$ git checkout -- composer.lock | |
user@host:/project-dir[master]$ git status | |
On branch master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @var $splFileInfo SplFileInfo | |
*/ | |
$root = '/etc/nginx'; | |
$rdi = new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS); | |
$iterator = new RecursiveIteratorIterator($rdi); | |
//$iterator = new RegexIterator($iterator, '/\.txt/', RegexIterator::MATCH); | |
$tree = []; | |
foreach ($iterator as $splFileInfo) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
####################################### | |
# Formats a string with ANSI codes | |
# Arguments: | |
# $1 the string to be formatted | |
# FG_* the foreground color, available values | |
# FG_BLACK | |
# FG_RED | |
# FG_GREEN |
NewerOlder