Skip to content

Instantly share code, notes, and snippets.

View djhworld's full-sized avatar

Daniel Harper djhworld

View GitHub Profile
#!/bin/bash
# could probably get this to work with GNU grep but using ripgrep for now
check=$(cat /proc/acpi/wakeup | /usr/bin/rg XHC1 | /usr/bin/rg disabled)
if [[ $check == '' ]]; then
echo "Wakeup from XHC1 is enabled - disabling!"
echo XHC1 > /proc/acpi/wakeup
else
  UPDATE `NEXUS 5` 
     SET `VERSION`='5.0', `BUILD`='LRX21O', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='4.4.4' && `BUILD`='KTU84P' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;

A manual OTA for rooted hammerheads, quasi.

@djhworld
djhworld / count.rs
Created December 30, 2018 10:55
improved version
use std::collections::HashMap;
use std::io;
use std::io::BufRead;
struct Counter {
items: HashMap<String, usize>,
}
impl Counter {
fn new() -> Counter {
package main
import (
"bufio"
"fmt"
"os"
)
type Counter struct {
uniqueItems map[string]int

Keybase proof

I hereby claim:

  • I am djhworld on github.
  • I am djhworld (https://keybase.io/djhworld) on keybase.
  • I have a public key ASBuDsFo40OPjQUbBHDIr1dXS_7QOXG7NGajhjKYUIzVnQo

To claim this, I am signing this object:

@djhworld
djhworld / haskell_one_liners
Created June 2, 2011 21:34
Haskell One Liners
-- Inspired by http://solog.co/47/10-scala-one-liners-to-impress-your-friends/
-- Double everything in a list
map (*2) [1..10]
-- Sum a list of numbers
sum [1..1000]
-- Verify if exists in a string (thanks to hammar for this: http://stackoverflow.com/questions/6224315/how-to-verify-if-some-items-are-in-a-list)
any (`elem` ["haskell", "ghc", "monads", "cabal"]) $ words "this is a piece of example text talking about haskell and ghc"
@djhworld
djhworld / ngrams.go
Created April 11, 2014 21:28
Ngrams algorithm
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func main() {
#!/bin/bash
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
# test devised by gordonDrogon
function testpin {
pin=$1
echo -n "Testing GPIO pin #$pin..."
gpio mode $pin in
public class BeadSort {
private static final int BEAD = 1;
public void sort(int[] array) {
int[][] abacus = populateAbacusAndWipeInput(array);
for (int pole = 0; pole < abacus[0].length; pole++) {
int poleRow = abacus.length - 1;
for (int currentRow = poleRow; currentRow >= 0; currentRow--) {
if (abacus[currentRow][pole] == BEAD) {
@djhworld
djhworld / nexus-android-update.sh
Created October 24, 2015 11:04
flash nexus 5 to newer android version
function prompt {
echo $1
read -p "Ready? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
else
echo "Quitting"
exit