This file contains hidden or 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
function createSpiral(dimension) { | |
console.time(); | |
// square array generator | |
const matrix = (dimension) => { | |
return new Array(dimension).fill(0).map((obj, idx) => { | |
return obj[idx] = new Array(dimension).fill(0); | |
}); | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 | |
# https://api.slack.com/custom-integrations/legacy-tokens | |
APIKEY="<INSERT_LEGACY_API_TOKEN>" | |
while true | |
do | |
SONG=$(osascript -e 'tell application "Spotify" to name of current track as string') | |
ARTIST=$(osascript -e 'tell application "Spotify" to artist of current track as string') | |
URLSONG=$(echo "$SONG" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"') | |
URLARTIST=$(echo "$ARTIST" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"') | |
curl -X POST -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$URLARTIST"%20%2D%20"$URLSONG"%22%2C%22status_emoji%22%3A%22%3Aheadphones%3A%22%7D" > /dev/null |
This file contains hidden or 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
const fs = require("fs"); | |
const Uint64BE = require("int64-buffer").Uint64BE; | |
let offset = 0; | |
let arr; | |
fs.readFile("txnlog.dat", function(err, data) { | |
arr = Buffer.from(data); | |
// Header | |
const header = arr.slice(offset,offset+=4).toString('utf8'); | |
const version = arr.slice(offset,offset+=1).toString('hex'); |
This file contains hidden or 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
const fs = require("fs"); | |
const eol = require("os").EOL; | |
const plans_data = convertCSVtoJSON(fs.readFileSync("plans.csv", "utf8")); | |
const zips_data = convertCSVtoJSON(fs.readFileSync("zips.csv", "utf8")); | |
solve("slcsp.csv"); | |
// CSV to JSON parser | |
function convertCSVtoJSON(csv) { | |
let result = []; |
This file contains hidden or 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
// | |
// PROBLEM | |
// | |
// Taco (our mascot) is pretty terrible at writing code, but his recommendation still // carries a lot of weight. | |
// He's put together a page that we can use to get his latest # recommendations: https://taco-spolsky.github.io/ | |
// | |
// To complete your application, please include a link to Taco's recommendation page | |
// in the field below (hopefully a link that leads to a page where you are the one | |
// being recommended!) | |
// |
This file contains hidden or 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
// PROBLEM: | |
// | |
// Sort the characters in the following string: | |
// | |
// abcdefghijklmnopqrstuvwxyz_ | |
// | |
// by the number of times the character appears in the following text (descending): | |
// | |
// Note: the text scrolls. |
This file contains hidden or 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
// PROBLEM: | |
// | |
// Find a 9 letter string of characters that contains only letters from | |
// | |
// acdegilmnoprstuw | |
// | |
// such that the hash(the_string) is | |
// | |
// 945924806726376 |
This file contains hidden or 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
/** | |
* @fileoverview Utility functions related to the user agent. | |
*/ | |
function isIOS() { | |
return /iPhone|iPad|iPod/i.test(navigator.userAgent); | |
} | |
This file contains hidden or 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 python | |
""" Convert an image (argv[1]) to an ANSI text string (xterm-256color) | |
Original readme from colortrans.py follows: | |
Nice long listing of all 256 colors and their codes. Useful for | |
developing console color themes, or even script output schemes. | |
Resources: |
NewerOlder