Skip to content

Instantly share code, notes, and snippets.

View seancheung's full-sized avatar
😅

Sean seancheung

😅
  • Hangzhou, Zhejiang/China
View GitHub Profile
@pauloconnor
pauloconnor / gist:4707710
Last active December 1, 2022 09:33
Logstash Mutate Filter for stripping Linux color codes from log files
# Get rid of color codes
mutate {
gsub => ["message", "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", ""]
}
# The Script
```sh
git log v2.1.0...v2.1.1 --pretty=format:'<li> <a href="http://github.com/jerel/<project>/commit/%H">view commit &bull;</a> %s</li> ' --reverse | grep "#changelog"
```
# A git alias for the command:
@branneman
branneman / better-nodejs-require-paths.md
Last active June 12, 2024 02:40
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

anonymous
anonymous / download_apk.sh
Last active March 23, 2024 15:54
Bash script for pulling APK's from Non-rooted android devices
#!/bin/sh
if test $# -lt 1 ; then
echo "Usage: download_apk.sh <GooglePlayPackageName>"
exit 1
fi
PACKAGE=$1
APK_PATH=`adb shell pm list packages -f -3 | grep $PACKAGE | cut -d'=' -f 1 | cut -c9-`
echo "Pulling $APK_PATH from device"
echo `adb pull ${APK_PATH} ./${PACKAGE}.apk`
@Shoozza
Shoozza / agent.cmd
Last active April 20, 2022 02:45
Make Cmder work with ssh-agent
@ECHO OFF
SETLOCAL
GOTO:MAIN
REM
REM Info functions start
REM
REM Display version and copyright information
:VERSION
@pyrtsa
pyrtsa / version.bash
Last active March 23, 2023 06:47
Xcode: Set version and build number from Git
#!/bin/bash
# Xcode: Set version and build number from Git
# --------------------------------------------
#
# This script sets the version number `CFBundleShortVersionString` to one of
#
# - `1.2.3` -- for the tagged commit `v1.2.3` or a hyphen-separated prerelease,
# e.g. `v1.2.3-alpha`, `v1.2.3-alpha.2`, `v1.2.3-beta`, `v1.2.3-rc`.
# - `1.2.3-7-gabc1234` -- at commit `abc1234`, 7 commits after `v1.2.3`,
# - `1.2.3-7-gabc1234-dirty` -- when there are uncommitted changes, or
@kristopherjohnson
kristopherjohnson / dlog.h
Last active January 19, 2021 02:52
DLog/ALog/ULog macros for Objective-C, from http://overbythere.co.uk/blog/2012/01/alternatives-nslog
// Original source for DLog/ALog/ULog: http://overbythere.co.uk/blog/2012/01/alternatives-nslog
// Log in DEBUG build only
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
// Always log
@alexandru-calinoiu
alexandru-calinoiu / gist:451bb7cdaa1e67111ae7
Last active January 29, 2022 05:04
Send a CURL get request with an array param
This took me longer that I will like to find out
curl "http://localhost:3000/v1/collections/42/items?fields[]=synopsis" -v -H "Content-Type: application/json" -H "X-Session-Token: xxx" --globoff
@etes
etes / pi_mount_usb.md
Last active June 15, 2024 13:39
How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

Follow the simple steps in the order mentioned below to have your USB drive mounted on your Raspberry Pi every time you boot it.

These steps are required especially if your are setting up a Samba share, or a 24x7 torrent downloader, or alike where your Raspberry Pi must have your external storage already mounted and ready for access by the services / daemons.

Step 0. Plug in your USB HDD / Drive to Raspberry Pi If you are using a NTFS formatted drive, install the following

@kjs3
kjs3 / server.js
Created December 3, 2015 20:26
Reloading express routes/middleware on file change WITHOUT restarting node process.
if ( process.env.NODE_ENV === 'production' ) {
// dev runs with babel-node so this isn't necessary
require('babel-core/register'); // this includes the polyfill
require('newrelic');
}
import 'source-map-support/register'
import Debug from 'debug'
import express from 'express'