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
| import Cocoa | |
| import AVFoundation | |
| // inspiration: https://www.youtube.com/watch?v=1_PUdhLQsZQ | |
| class ViewController: NSViewController { | |
| @IBOutlet weak var videoView: NSView! | |
| private var cameraSession = AVCaptureSession() | |
| private var camera: AVCaptureDevice! |
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
| import sublime | |
| import sublime_plugin | |
| import re | |
| import os | |
| class OpenJournalReferencedOnThisLineCommand(sublime_plugin.TextCommand): | |
| def run(self, edit): | |
| region = self.view.sel()[0] | |
| line_range = self.view.line(region) | |
| line = self.view.substr(line_range) |
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
| # ~/.config/sublime-text-3/Packages/User/MarkdownCheckboxes.py | |
| import sublime, sublime_plugin | |
| import re | |
| from time import strftime | |
| def now(): | |
| return strftime("%Y-%m-%dT%H:%M:%S") | |
| timestampRegex = r"\s*\(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\)" |
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 tableToJson(table) { | |
| var data = []; | |
| // first row needs to be headers | |
| var headers = []; | |
| for (var i=0; i<table.rows[0].cells.length; i++) { | |
| headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,''); | |
| } | |
| // go through cells |
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
| # usage: | |
| # ruby organize_mp3s.rb /path/to/mp3/directory/ | |
| require 'shellwords' | |
| def clean filename | |
| return "" unless filename | |
| filename.gsub(/[^0-9A-Za-z.\- ]/, '_') | |
| end |
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
| import React, { Component } from "react"; | |
| import "./App.css"; | |
| import { db } from "./firebase"; | |
| window.db = db; | |
| class App extends Component { | |
| state = { | |
| title: "Loading...", |
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
| import React, { Component } from "react"; | |
| import "./App.css"; | |
| import { db } from "./firebase"; | |
| window.db = db; | |
| class App extends Component { | |
| state = { | |
| title: "Loading...", |
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
| def pi_monte(n=100_000) | |
| inside = total = 0 | |
| n.times{ | |
| x, y = rand*2-1, rand*2-1 | |
| d = Math.sqrt(x**2+y**2) | |
| if d < 1 | |
| inside += 1 | |
| end |
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
| # runs in about 10s on my 1.1GHz MacBook. | |
| equation = "x+13*x/x+x+12*x-x-11+x*x/x-10==66".gsub("x", "%.1f") | |
| puts (1..9).to_a.permutation.map{|nums|equation%nums}.select{|eq| eval(eq)} |
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
| mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader file.wma && lame -m s audiodump.wav -o file.mp3 && rm audiodump.wav |