Skip to content

Instantly share code, notes, and snippets.

View peterchaula's full-sized avatar

Peter Chaula peterchaula

  • Johannesburg, South Africa
View GitHub Profile
#!/bin/bash
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n $1 > $CPUFREQ; done
/**
Fix this code
var multiplyByIndex = [];
for (var i = 0; i < 100; i ++) {
multiplyByIndex[i] = function(inputNum) {
return inputNum * i;
};
}
@peterchaula
peterchaula / hello.bf
Created November 19, 2016 07:05
Hello world in Brainfuck
++++++++[->+++++++++<]>.>++++[<+++++++>-]<+.>[-]+++[<++>-]<+..+++.>+++++++++++[<------>-]<-.>++++[<--->-]<.>+++++++[<++++++++>-]<-.>++++++[<++++>-]<.+++.------.>++[<---->-]<.>+++++++++++[<------>-]<-.
@peterchaula
peterchaula / clean-branches.sh
Created December 21, 2016 09:52
Leave master as the only branch
!#/bin/sh
git checkout master; \
git remote prune origin; \
for i in `git branch`; do
echo $i;
git branch -D $i;
done
@peterchaula
peterchaula / benchmark.php
Last active December 30, 2016 08:45 — forked from BlakeGardner/benchmark.php
Benchmark of all the hashing algorithms provided by PHP
<?php
foreach (hash_algos() as $algo) {
$start_time = microtime(TRUE);
for ($index = 0; $index <= 500000; $index++) {
$hash = hash($algo, $index);
}
@peterchaula
peterchaula / commit-and-push.sh
Created March 10, 2017 17:11
Commit and push in the case of a fire
DATE="`date +%Y-%m-%d_%H_%M`"; \
git add .; \
git commit -m "Save ${DATE}"; \
git push origin HEAD:backup-${DATE}
@peterchaula
peterchaula / history_stack.sh
Last active April 25, 2017 08:57
Implement a back stack in bash
#bash alias
alias cd="pushd . && cd"
DATE="`date +%Y-%m-%d_%H_%M`"; \
git add .; \
git commit -m "Backup ${DATE}"; \
git push origin HEAD:backup-${DATE}
@peterchaula
peterchaula / phone_numbers.cpp
Last active February 17, 2019 11:47
Put that cleanLine function back in
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
//void function declaration
string cleanLine(string line);
int main( )
{
adb shell "mkdir -p /sdcard/tunnel" #-p flag will make the mkdir silent if the dir already exists
adb shell "run-as <package-id> cp -r /data/data/<package-id>/ /sdcard/tunnel"
adb pull /sdcard/tunnel <destination-dir>/