Skip to content

Instantly share code, notes, and snippets.

View rednebmas's full-sized avatar

Sam Bender rednebmas

View GitHub Profile
@rednebmas
rednebmas / 0_reuse_code.js
Created July 21, 2014 04:42
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
@rednebmas
rednebmas / print_html.js
Created February 12, 2016 20:51
Print document HTML in an Anki Card
<script>
var pretag = document.createElement("pre");
pretag.innerHTML = document.getElementsByTagName("html")[0].outerHTML.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
return '&#'+i.charCodeAt(0)+';';
});
document.body.appendChild(pretag);
</script>
@rednebmas
rednebmas / test.html
Last active February 27, 2016 06:42
Responsive HTML "table cell" with vertically centered detail arrow
<!-- Created for my INFO 360 project ProcrastiNo -->
<!-- Based on code from http://jsfiddle.net/Mandarinazul/WMLd4/ -->
<!DOCTYPE html>
<html lang="en">
<body>
<style>
div {
font-family: Tahoma, Verdana sans-serif;
box-sizing: border-box;
-moz-box-sizing: border-box;
@rednebmas
rednebmas / useful_and_common.bash
Last active August 10, 2016 15:05
Useful and common bash commands
#########
## Git ##
#########
# search diff of dangling commits for the word AVCaptureDevice
git fsck --no-reflog | awk '/dangling commit/ {print $3}' | \
while read ref; do if [ "`git show -p $ref|grep -c AVCaptureDevice`" -ne 0 ]; then echo $ref ; fi ; done
# list git commit messages for dangling commits
git fsck --lost-found | grep "dangling commit" | cut -d" " -f 3 | xargs -I "{}" git show --stat "{}" # view git messages for dangling commits
@rednebmas
rednebmas / bash-color-grid.sh
Created August 26, 2016 16:04
Prints all bash prompt colors
# Thanks to plasmarob (http://unix.stackexchange.com/a/285956)
function colorgrid( )
{
iter=16
while [ $iter -lt 52 ]
do
second=$[$iter+36]
third=$[$second+36]
four=$[$third+36]
five=$[$four+36]
{
"auto_complete": true,
"caret_style": "solid",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"folder_exclude_patterns":
[
".git",
"doc"
],
"font_size": 13,
@rednebmas
rednebmas / nil.js
Last active January 12, 2017 01:20
Nil.js
/*
The Nil object behaves similarily to nil in Objective-C. You can infinitely
chain calls or property accessors on it and it will never throw an exception.
I developed this for unit testing.
Example usage:
var nil = new Nil();
console.log(nil.infinitelyChainsCalls().or.properties.withoutRepercussions());
Based on code from http://stackoverflow.com/a/29723887/337934
Proxy documentation: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Proxy
*/
@rednebmas
rednebmas / karabiner.private.xml
Last active January 12, 2017 17:11
Karabiner (https://pqrs.org/osx/karabiner/) customization file
<?xml version="1.0"?>
<root>
<appdef>
<appname>GOOGLE_CHROME</appname>
<equal>com.google.Chrome</equal>
</appdef>
<appdef>
<appname>TERMINAL</appname>
@rednebmas
rednebmas / an_obj_pattern.js
Created February 4, 2017 23:19
Neat javascript object/class pattern
var myClass = function(constructorParam) { return {
/** object notation properties **/
x: "it ",
_state: 'awesome',
/** Getters and setters! **/
get state() {
return this._state;
},
set state(value) {
@rednebmas
rednebmas / XcodeSnippets.m
Last active September 22, 2017 05:35
My user defined code snippets for ObjC dev in Xcode
// completion shortcut: @propstrong
@property (nonatomic, strong) <#type#> *<#name#>;
// completion shortcut: @propweak
@property (nonatomic, weak) <#type#> *<#name#>;
// completion shortcut: @propassign
@property (nonatomic, assign) <#type#> <#name#>;
// completion shortcut: dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>