Skip to content

Instantly share code, notes, and snippets.

View brettinternet's full-sized avatar
👋

Brett brettinternet

👋
View GitHub Profile
@brettinternet
brettinternet / sudo-keepalive-example.sh
Created March 8, 2017 06:46 — forked from cowboy/sudo-keepalive-example.sh
Bash: Sudo keep-alive (good for long-running scripts that need sudo internally but shouldn't be run with sudo)
#!/bin/bash
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Example: do stuff over the next 30+ mins that requires sudo here or there.
function wait() {

Keybase proof

I hereby claim:

  • I am brettinternet on github.
  • I am brettinternet (https://keybase.io/brettinternet) on keybase.
  • I have a public key whose fingerprint is 4836 109F 6EAE 10A4 201D DC18 21FF F74B 9B1B 795A

To claim this, I am signing this object:

@brettinternet
brettinternet / bang-bang.js
Created March 13, 2017 23:25
!!expression operator
!!false === false
!!true === true
!!0 === false
!!parseInt("foo") === false // NaN is falsy
!!1 === true
!!-1 === true // -1 is truthy
!!"" === false // empty string is falsy
!!"foo" === true // non-empty string is truthy
@brettinternet
brettinternet / notepad.html
Created March 15, 2017 21:01 — forked from jdkanani/notepad.html
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@brettinternet
brettinternet / users.json
Created March 24, 2017 15:40
dummy data for students
[
{
"id": 1,
"name": "Leanne Graham",
"img": "https://randomuser.me/api/portraits/women/33.jpg",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
let fibonacci = (n) => {
if(n <= 2) {
return 1;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
};
@brettinternet
brettinternet / two-cities.txt
Created May 13, 2017 20:00
for an api call on a python example
It was the best of times
it was the worst of times
it was the age of wisdom
it was the age of foolishness
it was the epoch of belief
it was the epoch of incredulity
it was the season of Light
it was the season of Darkness
it was the spring of hope
it was the winter of despair

This guy discovered a CodeWars hack that tricks the tests into passing.

class NilClass
  def ==(_)
    true
  end
end
def mymethod
@brettinternet
brettinternet / time_del.py
Last active July 10, 2017 20:58 — forked from mattieb/time_del.py
Time various methods of removing a possibly-present item from a dict
#!/usr/bin/python3
import time
def new_d():
return {
1: 2, 3: 4, 5: 6, 7: 8, 9: 10,
11: 12, 13: 14, 15: 16, 17: 18, 19: 20
}

API

URL Method Query Body Data returned Permissions Description
api/users/ GET List of users List users for requesting user's company
company=# filter by company Admins only

Servers

Name