Skip to content

Instantly share code, notes, and snippets.

@tarnagas
tarnagas / sample-count-grouped.sql
Created August 16, 2017 09:49
sample count grouped sql
SELECT *, (
case when sku = 'W556B' then 1 else 0 end +
case when product_type = 'Tapis' then 1 else 0 end
) as cnt from etl_raw_import_art
WHERE (sku = 'W556B' or product_type = 'Tapis')
order by
case when sku = 'W556B' then 1 else 0 end +
case when product_type = 'Tapis' then 1 else 0 end
DESC
@tarnagas
tarnagas / sample-liquid-yaml.rb
Created August 16, 2017 10:26
Sample use of liquid (gem) to generate YAML
#!/usr/bin/env ruby
require 'liquid'
template = <<-HEREDOC
data:
{%- for item in plops %}
- {{ item }}
{%- endfor %}
host: "sample.local"
@tarnagas
tarnagas / gist:0466c4aa76d08f29b7c050f443ab50da
Created March 6, 2018 14:18 — forked from nickwanhere/gist:85bfbe8143ded6a30acb
Programmatically set magento locale
<?php
$locale = 'nl_NL';
Mage::app()->getLocale()->setLocaleCode($locale);
Mage::getSingleton('core/translate')->setLocale($locale)->init('frontend', true);
//http://www.kennydeckers.com/programatically-set-locale-language-magento/
?>
@tarnagas
tarnagas / max.sql
Created November 15, 2018 10:34
SQL MAX (LEFT JOIN alternative)
SELECT * FROM events
LEFT JOIN events as e2 ON e2.tag_id = events.tag_id
AND e2.change_dt > events.change_dt
WHERE e2.change_dt IS NULL
/**
* kotlinc/bin/kotlinc hello.kt -include-runtime -d hello.jar
* java -jar hello.jar
*
* https://github.com/Zenika/docker-kotlin/blob/master/1.3/jdk12/Dockerfile
*/
fun main(args: Array<String>) {
println("Hello, %s!".format(args[0]))
}
@tarnagas
tarnagas / .screenrc
Created February 15, 2019 09:57
Minimal config for screen (.screenrc)
# Global configration
# --------------------------------------------------------------------
startup_message off
autodetach on
nonblock on
altscreen on
# define a bigger scrollback, default is 100 lines
defscrollback 1000
term screen-256color
@tarnagas
tarnagas / import.sh
Last active February 20, 2019 14:55
Import dump generated by mysqlpump
#!/usr/bin/env sh
# Sample of use:
#
# ```sh
# sh import.sh backuped_database.sql
# ```
#
# @see https://hub.docker.com/r/mysql/mysql-server/
# @see https://dev.mysql.com/doc/refman/8.0/en/mysqlpump.html
'use strict'
/**
* Sample of use
*
* ```js
* import { path as MediasPath } from './vue/medias/forms'
* import { content_type as WorksContentType } from './vue/works/forms'
* appify({
* components: {
@tarnagas
tarnagas / rasp-backup
Last active June 12, 2019 09:45
Save raspberry state as a compressed img file
#!/usr/bin/env sh
# Sample of use:
#
# rasp-backup /dev/sdc
set -eu
IMG_FILE=rasp.$(date +%Y%m%d.%s).img.gz
GZIP_BIN="$(which pigz)" # tries for multithread gzip
test -z "${GZIP_BIN}" && {
git branch --merged master | grep -Ev "^\s+(release/.*|master)$" | while read line; do git branch -d "$line" && git push origin --delete "$line"; done