Skip to content

Instantly share code, notes, and snippets.

@ptthisdan
ptthisdan / hash.c
Created December 9, 2013 11:57 — forked from tonious/hash.c
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
struct entry_s {
char *key;
char *value;
@ptthisdan
ptthisdan / Makefile
Created December 9, 2013 11:58 — forked from ankurs/Makefile
hashtable implementation in c
CC = gcc -fPIC
LDFLAGS = -lm
# set DEBUG options
ifdef DEBUG
CFLAGS = -Wall -Wextra -ggdb -pg -DDEBUG
else
CFLAGS = -Wall -O2
endif
@ptthisdan
ptthisdan / 0_reuse_code.js
Created January 2, 2014 08:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#InstallKeybdHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; OPTIONAL: For those who use Home/End more than PgUp/PgDown, this flips their use with the Fn key.
; If you want the buttons to function as they are, add a semicolon (;) to the beginning of each line below.
Home::PgUp
End::PgDn
PgUp::Home
@ptthisdan
ptthisdan / ngrok-selfhosting-setup.md
Created March 21, 2016 08:33 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@ptthisdan
ptthisdan / jdks.sh
Created December 19, 2017 08:17 — forked from Noyabronok/jdks.sh
JDK switching
#list available jdks
alias jdks="/usr/libexec/java_home -V"
# jdk version switching - e.g. `jdk 6` will switch to version 1.6
function jdk() {
echo "Switching java version";
export JAVA_HOME=`/usr/libexec/java_home -v 1.$1`;
java -version;
}
@ptthisdan
ptthisdan / delete_outdated_photos.sh
Last active February 18, 2021 12:35
adb delete photos older than X Days
find /sdcard/DCIM* -mtime +180 -exec rm {} ";"
@ptthisdan
ptthisdan / powerchk.sh
Created March 13, 2021 05:19
ping the router, if ping fail>N, shutdown NAS
#!/bin/bash
# @author JasonLiu
# @since 2019/12/25
# @description ping the router,if power shutdown,router will shutdown,ping will fail,if ping fail>N,shutdown NAS
# idea first come from http://koolshare.cn/thread-120821-1-1.html
# */1 * * * * /share/Project/shell/powerchk.v5.sh >> /share/Project/shell/log/power.log
# crontab /etc/config/crontab && /etc/init.d/crond.sh restart
function usage()
{