Skip to content

Instantly share code, notes, and snippets.

@alfchee
alfchee / git-prune.bash
Created May 3, 2021 16:43
Delete all merged branches in remote, excluding branches `dev` and `main`.
git branch --merged | egrep -v "(^\*|main|dev)" | xargs git branch -d
@alfchee
alfchee / debugg_trace.php
Created October 26, 2018 16:43
Trace the stack of calls for your break var_dump()
// useful line of code to generate a backtrace
array_walk(debug_backtrace(),create_function('$a,$b','print "{$a[\'function\']}()(".basename($a[\'file\']).":{$a[\'line\']}); ";')); die();
@alfchee
alfchee / TimelineComponent.js
Created September 7, 2018 16:01
Idea about time ranges solutions
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
@Component({
selector: 'app-timeline',
templateUrl: './timeline.component.html',
styleUrls: ['./timeline.component.css']
})
export class TimelineComponent implements OnInit {
@alfchee
alfchee / redis-server
Created July 16, 2018 02:24 — forked from nexdrew/redis-server
Example files for running Redis on CentOS 7 (after manual install)
/var/lib/redis/logs/redis.log {
daily
rotate 14
copytruncate
delaycompress
compress
notifempty
missingok
}
@alfchee
alfchee / simplesaml.conf
Created July 14, 2018 18:18
Simple SAML PHP configuration, to incluse SimpleSAMLPHP as part of your domain.com/simplesaml
{
listen 80;
server_name mydomain.com;
location ^~ /simplesaml {
alias /var/simplesamlphp/www;
location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
@alfchee
alfchee / install_redis_on_ubuntu.md
Created June 7, 2018 17:44 — forked from torgeir/install_redis_on_ubuntu.md
Redis 2.4.8 Install on Ubuntu 10.04

Installation commands:

$ wget http://redis.googlecode.com/files/redis-2.4.8.tar.gz
$ tar xvfz redis-2.4.8.tar.gz 
$ cd redis-2.4.8/
$ mkdir -p /opt/redis
$ make PREFIX=/opt/redis install
$ cp redis.conf /opt/redis/redis.conf
$ chown -R redis:redis /opt/redis
@alfchee
alfchee / slice_exists.go
Created April 26, 2018 00:52 — forked from r6m/slice_exists.go
golang check if item exists in slice
package main
import(
"fmt"
"reflect"
)
func main() {
items := []int{1,2,3,4,5,6}
fmt.Println(SliceExists(items, 5)) // returns true
@alfchee
alfchee / remove-unused-branches.sh
Created November 27, 2017 16:19
This simple script will prune the removed branches on remote, list the branches that has a state of "gone" and then remove them
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
@alfchee
alfchee / wkhtmltopdf.sh
Created July 7, 2017 21:11 — forked from Rajeshr34/wkhtmltopdf.sh
Wkhtmltopdf With Patched QT Setup Ubuntu 16+
cd ~
wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin
apt-get install -y openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig
@alfchee
alfchee / sec_tutorial.md
Created March 9, 2017 06:46 — forked from tgrall/sec_tutorial.md
MongoDB Security Tutorial

#Simple MongoDB Security Tutorial

###1 - Start mongod without any "security option"

$ mongod --port 27017