Skip to content

Instantly share code, notes, and snippets.

View inceabdullah's full-sized avatar
🏢
Working from office

inceabdullah

🏢
Working from office
View GitHub Profile
@koshigoe
koshigoe / mount-ram.sh
Created February 11, 2011 14:57
Like tmpfs in Mac OSX
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@danott
danott / json_storage.js
Created April 26, 2011 15:51
Override localStorage and sessionStorage's getter and setter function to allow for objects/arrays to be stored as well.
/* json_storage.js
* @danott
* 26 APR 2011
*
* Building on a thread from Stack Overflow, override localStorage and sessionStorage's
* getter and setter functions to allow for storing objects and arrays.
*
* Original thread:
* http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
*/
@vratiu
vratiu / .bash_aliases
Last active June 26, 2024 08:15
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@hosackm
hosackm / flaskaudiostream.py
Created September 2, 2015 22:30
Flask streaming an audio file
from flask import Flask, Response
app = Flask(__name__)
@app.route("/wav")
def streamwav():
def generate():
with open("signals/song.wav", "rb") as fwav:
data = fwav.read(1024)
@dpino
dpino / ns-inet.sh
Last active June 19, 2024 11:31
Setup a network namespace with Internet access
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@jgrodziski
jgrodziski / docker-aliases.sh
Last active June 23, 2024 03:01
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@tbaschak
tbaschak / netbps.pl
Created March 2, 2017 05:16
Measures BPS coming out of tcpdump. Usage: `tcpdump -l -e -n ether broadcast | ./netbps`. Un-Modified from http://superuser.com/questions/356907/how-to-get-real-time-network-statistics-in-linux-with-kb-mb-bytes-format-and-for Raw
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes;
my $reporting_interval = 5.0; # seconds
my $bytes_this_interval = 0;
my $start_time = [Time::HiRes::gettimeofday()];
STDOUT->autoflush(1);
@jhazelwo
jhazelwo / iptables.sh
Last active March 5, 2024 02:52
iptables rules to only allow VPN traffic AND let user SSH to VPN server itself.
#!/bin/sh
# by: "John Hazelwood" <jhazelwo@users.noreply.github.com>
#
# iptables rules to only allow VPN traffic AND let user SSH to VPN server itself.
# Use this on a CentOS/RedHat server you have set up to be a NAT firewall for your network.
# This will force ALL Internet traffic to go over the VPN
# and will BLOCK ALL Internet TRAFFIC if VPN is not running!
#
# use `service iptables save` to save the rules to /etc/sysconfig/iptables
# made
@robcalcroft
robcalcroft / createSha256CspHash.js
Created May 20, 2018 22:23
Create a sha256 hash of a string in Node.js to use in a CSP
const crypto = require('crypto');
function createSha256CspHash(content) {
return 'sha256-' + crypto.createHash('sha256').update(content).digest('base64');
}
@katharinepadilha
katharinepadilha / App.js
Last active December 1, 2019 20:03
App.js setup for firebase notifications
//...
async getToken() {
let fcmToken = await AsyncStorage.getItem('fcmToken');
if (!fcmToken) {
fcmToken = await firebase.messaging().getToken();
if (fcmToken) {
await AsyncStorage.setItem('fcmToken', fcmToken);
}
}
}