This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo echo "Thanks." | |
for domain in $(defaults domains | sed 's/,//g' ) | |
do | |
echo "$domain $(defaults read $domain)" >> /tmp/apple_defaults.txt | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Question found here: | |
// https://stackoverflow.com/questions/32527026/shortest-path-in-javascript | |
// Based on the first accepted answer | |
"use strict" | |
const expect = require('expect.js') | |
class Graph { | |
constructor(props) { | |
this.neighbors = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
x=1 | |
while [ $x -le 100 ] | |
do | |
if [[ 0 -eq "($x%3) + ($x%5)" ]] | |
then | |
# Check if divide by 3 & 5 # | |
echo "fizz buzz" | |
elif [[ 0 -eq "($x%5)" ]] | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testhelpers | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/httptest" | |
"net/url" | |
"github.com/jmcvetta/neoism" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// https://www.geeksforgeeks.org/find-if-given-matrix-is-toeplitz-or-not/ | |
class Toeplitz { | |
static check(matrix) { | |
for (var i = 1; i < matrix.length - 1; i++) { | |
let row = matrix[i] | |
let prevRow = matrix[i - 1] | |
for (var j = 1; j < row.length - 1; j++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merged_branches(){ | |
local current_branch=$(git rev-parse --abbrev-ref HEAD) | |
for branch in $(git branch --merged | cut -c3-) | |
do | |
echo "Branch $branch is already merged into $current_branch." | |
echo "Would you like to delete it? [Y]es/[N]o " | |
read REPLY | |
if [[ $REPLY =~ ^[Yy] ]]; then | |
git branch -d $branch | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from ruby shellwords | |
var escapeShell = function(str) { | |
// An empty argument will be skipped, so return empty quotes. | |
if (str === "" || str === null) return "''" | |
var command = str; | |
// Treat multibyte characters as is. It is caller's responsibility | |
// to encode the string in the right encoding for the shell | |
// environment. | |
command = command.replace(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\$1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
Node = Struct.new(:value, :left, :right) | |
def create_tree(nodes, root=nil, idx=0) | |
if nodes.size > idx | |
root = Node.new(nodes[idx]) | |
root.left = create_tree(nodes, root.left, 2 * idx + 1) | |
root.right = create_tree(nodes, root.right, 2 * idx + 2) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" standalone="no"?> | |
<application xmlns="http://ns.adobe.com/air/application/2.6"> | |
<!-- Adobe AIR Application Descriptor File Template. | |
Specifies parameters for identifying, installing, and launching AIR applications. | |
xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/2.0 | |
The last segment of the namespace specifies the version | |
of the AIR runtime required for this application to run. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
require 'shellwords' | |
args = ARGV | |
size = args.size | |
tab_open = 'tell i term application "System Events" to keystroke "t" using {command down}' | |
v_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down}' | |
h_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down, shift down}' | |
go_left_one_pane = 'tell i term application "System Events" to key code 123 using {command down, option down}' | |
script_builder = Proc.new do |tell, command| |
NewerOlder