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
########## | |
# Win10 Initial Setup Script | |
# Author: Disassembler <disassembler@dasm.cz> | |
# Version: 1.7, 2016-08-15 | |
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/ | |
# THIS IS A PERSONALIZED VERSION | |
# This script leaves more MS defaults on, including MS security features. | |
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1 |
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
<?php | |
// Execute common code to connection to the database and start the session | |
require("../Login/common.php"); | |
if(empty($_SESSION['user'])) | |
{ | |
// If they are not, we redirect them to the login page. | |
header("Location: ../Login/login.php"); | |
// Without the die statement, people can view your members-only content without logging in. | |
die("Redirecting to login.php"); | |
} |
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
//assign the file contents to the array myJsonInput | |
$myJsonInput = file_get_contents("/Path/test.json"); | |
//Use json_decode to "Take a JSON encoded string and convert it into a PHP variable" | |
$json_arr=json_decode($myJsonInput,true); | |
//Create an empty array, $myLinks, to put the links in (in this example of pinboard bookmarks) | |
$mylinks = array(); | |
The test.json file is of the form: |
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
require ‘csv’ mydata = [] zips = File.open(‘zips.txt’) do |io| | |
h = {} | |
io.eachline do |line| | |
zip, freq = CSV.parseline line | |
h[zip]=freq | |
end | |
h | |
end | |
File.open(“target.xml”,“w”) do |target| File.open(‘ZIP_CODES.txt’) do |io| | |
io.eachline do |line| |
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 urllib | |
import re | |
def get_quote(symbol): | |
base_url = 'http://finance.google.com/finance?q=' | |
content = urllib.urlopen(base_url + symbol).read() | |
m = re.search('class="pr".*?>(.*?)<', content) | |
if m: | |
quote = m.group(1) | |
print symbol + " " + quote |
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
R statistics - basic data analysis with automation | |
To read in excel files | |
library ( gdata ) | |
# Note the forward slash on windows | |
# Set the working directory | |
setwd("C:/Documents and Settings/csnyder/Desktop/My Dropbox/Projects/NEC/Data/") | |
# Check it | |
(WD #mdat # mdat # Attach it if you wish |
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
# This takes csv data, and identifies it by column header (bob), sums the x column, and then adds a column with x/sum x | |
require ‘rubygems’ | |
require ‘fastercsv’ | |
csv="f,bob\na,0\nb,1\nc,2\nd,3\n" | |
table = FCSV.parse(csv, :headers => true, :converters => :integer) | |
xs = table['bob'].map{|x| x.to_i} | |
sum = Float table['bob'].inject{|sum,i| sum += i} | |
norm = xs.map{|x| x / sum} | |
table['n'] = norm |
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/env python | |
def find_jumble(jumble, word_file='/users/charleslsnyder/dictionary.txt'): | |
#you have to reset the word file to your dictionary and path | |
sorted_jumble = sort_chars(jumble) | |
for dictword in open(word_file, 'r').xreadlines(): | |
if sorted_jumble == sort_chars(dictword): | |
yield dictword | |
def sort_chars(word): | |
w = list(word.strip().lower()) |
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/python | |
# here is the link for the data: http://www.brewerydb.com/ | |
from bs4 import BeautifulSoup | |
# Start making the soup | |
soup = BeautifulSoup(open('/Users/weatherh/Documents/beerStyles.xml'), "lxml") | |
# Walk through each element in the XML by first using FindAll. Then we need to change their | |
# names and fix some nesting | |
head_tag = soup.root |
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
# Frequency count: | |
library(data.table) | |
dt = as.data.table(ops) | |
y <- dcast.data.table(dt[, bla := "count"], opCode ~ bla, drop=FALSE, fun.agg=length) | |
freq_ct_ops <- y[order(-y$count),] | |
View(freq_ct_ops) | |
# Now get the top 5% | |
freq_ct_ops[ , tail( .SD , ceiling( nrow(.SD) * .05 ) ) , by = count ] |
NewerOlder