Skip to content

Instantly share code, notes, and snippets.

@sylvia43
sylvia43 / naviancesort.user.js
Last active October 12, 2016 16:55
Naviance Sort "Colleges I'm Applying To"
// ==UserScript==
// @name Naviance Sort "Colleges I'm Applying To"
// @namespace http://shreyasr.me/
// @version 1.0
// @description Allow the user to sort Naviance's "Colleges I'm Applying To"
// @author Shreyas
// @match https://connection.naviance.com/family-connection/colleges/application/
// @grant none
// ==/UserScript==
package me.shreyasr.fbmp
import java.text.{DateFormat, DateFormatSymbols, SimpleDateFormat}
import java.util.{Date, Locale}
import net.ruippeixotog.scalascraper.browser.JsoupBrowser
import net.ruippeixotog.scalascraper.dsl.DSL.Extract._
import net.ruippeixotog.scalascraper.dsl.DSL._
object Parser {
@sylvia43
sylvia43 / capitalize.java
Created May 13, 2016 02:08
Java vs. Scala
public String capitalize(String str) {
String[] words = str.toLowerCase().split(" ");
for (int i = 0; i < words.length; i++) {
words[i] = Character.toUpperCase(words[i].charAt(0)) + words[i].substring(1);
}
return TextUtils.join(" ", words);
}
@sylvia43
sylvia43 / input.m
Last active May 9, 2016 17:09
Matrix cipher cracking
EDU>> A=[62 32 45 0 49 33 44 21 0 47 49 26 24 15; 165 84 115 0 124 90 112 55 0 122 132 65 67 54]
EDU>> B=[-5 2; 1 1]
EDU>> A*B
EDU>> B*A
EDU>> A.dim
EDU>> size(A)
EDU>> A(1, 1)
EDU>> A(2, 14) = 45
EDU>> B*A
EDU>> char(B*A+64)
@sylvia43
sylvia43 / Main.scala
Created December 2, 2015 17:54
Count the number of words in all Word documents in a directory.
import java.io.{File, FileInputStream, FilenameFilter}
import org.apache.poi.xwpf.extractor.XWPFWordExtractor
import org.apache.poi.xwpf.usermodel.XWPFDocument
object Main {
def main (args: Array[String]) {
println(getCountFromFolder("E:\\SchoolWork\\Running Start"))
}
@sylvia43
sylvia43 / frequency_estimator.py
Last active September 12, 2015 09:37 — forked from endolith/frequency_estimator.py
Frequency estimation methods in Python
from __future__ import division
from scikits.audiolab import flacread
from numpy.fft import rfft, irfft
from numpy import argmax, sqrt, mean, diff, log
from matplotlib.mlab import find
from scipy.signal import blackmanharris, fftconvolve
from time import time
import sys
from parabolic import parabolic
public class Timer {
private long startTime = 0;
public void start() {
startTime = System.currentTimeMillis();
}
public long stop() {
return System.currentTimeMillis() - startTime;
@sylvia43
sylvia43 / Window.java
Created August 24, 2015 23:29
Scala vs. Java
import asciiPanel.AsciiPanel;
import game.screens.Screen;
import game.screens.StartScreen;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class Window extends JFrame implements KeyListener {
/**
* Invoked when the garbage collector has detected that this instance is no longer reachable.
* The default implementation does nothing, but this method can be overridden to free resources.
*
* <p>Note that objects that override {@code finalize} are significantly more expensive than
* objects that don't. Finalizers may be run a long time after the object is no longer
* reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
* Note also that finalizers are run on a single VM-wide finalizer thread,
* so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
* for a class that has a native peer and needs to call a native method to destroy that peer.
private boolean containsEmoji(String string) {
// if you're doing it frequently, move the pattern compile into a static / member variable instead
Pattern p = Pattern.compile("[\\uD83C-\\uDBFF\\uDC00-\\uDFFF]+");
Matcher m = p.matcher(string);
return m.find();
}