Skip to content

Instantly share code, notes, and snippets.

View purmac's full-sized avatar

purmac purmac

  • Atlanta, GA
View GitHub Profile
@purmac
purmac / bing_rewards.ps1
Created March 29, 2020 17:35
Bing Rewards Automation Script
$resp =Invoke-WebRequest http://www.mit.edu/~ecprice/wordlist.10000 -UseBasicParsing
$wordList = $resp.content.split("`n")
for ($a = 0; $a -lt 35; $a++) {
$RandomWord = Get-Random $wordList
$RandomQuestion = Get-Random -InputObject("What+is+","Definition+of+","Pronunciation+of+","Thesaurus+","Examples+of+","prefixes+for+","suffixes+for+")
Start-Process microsoft-edge:http://www.bing.com/search?q=$RandomQuestion$RandomWord -WindowStyle Minimized
start-sleep -Milliseconds 1500
}
start-sleep -Milliseconds 2000
@purmac
purmac / gist:9bda4581861da2cb6ef2deb594737bde
Created January 24, 2019 03:12 — forked from rmondello/gist:b933231b1fcc83a7db0b
Exporting (iCloud) Keychain and Safari credentials to a CSV file

Exporting (iCloud) Keychain and Safari credentials to a CSV file

After my dad died, I wanted to be able to have access any of his online accounts going forward. My dad was a Safari user and used iCloud Keychain to sync his credentials across his devices. I don’t want to have to keep an OS X user account around just to access his accounts, so I wanted to export his credentials to a portable file.

This is the process I used to create a CSV file of his credentials in the format “example.com,user,pass”. This portable format would be pretty easy to import into 1Password or Safari in the future.

The way I went about this isn’t great; it opens up more opportunities for apps to control one’s Mac through Accessibility APIs, it writes plaintext passwords to disk, and it could use some cleaning up. A better approach might leverage the security command line tool that ships with OS X. That said, I found this method to be a fun illustration of what’s possible us

@purmac
purmac / osx-setup.sh
Created January 15, 2018 02:37 — forked from somebox/osx-setup.sh
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc
@purmac
purmac / Spark to calculate Avg
Created November 13, 2017 06:44 — forked from ytjia/Spark to calculate Avg
Calculate average value in spark.
var data = sc.parallelize(Seq(("A", 2), ("A", 4), ("B", 2), ("Z", 0), ("B", 10)))
// data: org.apache.spark.rdd.RDD[(java.lang.String, Int)] = ParallelCollectionRDD[31] at parallelize at <console>:12
val avgValue = data.mapValues((_, 1)
.reduceByKey((x, y) => (x._1 + y._1, x._2 + y._2))
.mapValues{ case (sum, count) => (1.0 * sum) / count }
.collectAsMap()
// avgValue: scala.collection.Map[java.lang.String,Double] = Map(Z -> 0.0, B -> 6.0, A -> 3.0)
@purmac
purmac / fetchInReact.js
Created November 12, 2017 08:45
Fetch call patten in React
componentDidMount() {
fetch(URL, { method: "get" })
.then(res => res.json())
.then(result => this.setWeatherData(result))
.catch(err => err);
}
@purmac
purmac / saveFilefromChrome.js
Created November 11, 2017 21:34
Save file from google chrome
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
% Give the file name
% Open the file and get the file descriptor
filename = "PrintingPath01.txt";
fd = fopen(filename, 'r');
linepattern = "#####\s*Line\s\d+"; % match #### Line {num}
nodepattern = "\s\d+\s"; % match " {num} "
coordpattern = "[-+]?[0-9]*\.?[0-9]+"; % match float number
line_count = 0;
data = {};
@purmac
purmac / tmux_cheatsheet.md
Last active November 5, 2017 22:27 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@purmac
purmac / tmux.md
Created November 1, 2017 20:01 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

function Counter({value}) {
return <h1>{value}</h1>
}
function Counter2(props) {
return <h1>{props.value}</h1>
}
const render = () => {
ReactDOM.render(<Counter value=1 />, document.getElementById('root'));