Skip to content

Instantly share code, notes, and snippets.

import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
@alcedo
alcedo / Problem_1225.java
Created September 2, 2013 10:43
1225 - Digit Counting
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
@alcedo
alcedo / Recursive Backtracking.txt
Last active December 22, 2015 12:28
Recursive Backtracking:
Recursive Backtracking:
usually involves a for loop + a recursion. (the for loop acts as a backtracking mechanism)
The requirements for a recursive solution are met in these ways.
.The problem is made smaller by taking one step in the space - by making one move.
.The base case occurs when the property has been fully satisfied and we arrive at the exit.
.The partial results are combined by putting the steps together in a way that is appropriate (perhaps printing them, or returning them as a list to some other program).
*important things to note: The base case is *usually* the solution to the problem.
@alcedo
alcedo / gist:6576530
Last active December 23, 2015 03:49
Angular JS Notes
AngularJS: $watch, $digest and $apply
Some Guidelines For Use:
$watch
DO use $watch in directives to update the DOM when a $scope value changes.
DON'T use $watch in a controller. It's hard to test and completely unnecessary in almost every case. Use a method on the scope to update the value(s) the watch was changing instead.
$digest/$apply
DO use $digest/$apply in directives to let Angular know you've made changes after an asynchronous call, such as a DOM event.
DO use $digest/$apply in services to let Angular know some asynchronous operation has returned, such as a WebSocket update, or an event from a 3rd party library like Facebook API.
@alcedo
alcedo / mailer.py
Created October 3, 2013 07:45
simple python file that reads an input file and sends out email via unix mail / sendmail command. demonstrates many of the core python functions and features.
#!/usr/bin/python
import sys
import os
import datetime
from subprocess import Popen, PIPE, call
from datetime import date, datetime, date, time
"""
Sends out an email via the unix mail command,
@alcedo
alcedo / yahoo_finance_downloader.py
Created October 7, 2013 08:52
Yahoo python downloader wrapper. Refer to documentations: http://victorliew.quora.com/3-Ways-to-programatically-download-stuff-from-Yahoo-Financials (YQL, Yahoo Finance)
import sys
import os
import time
from datetime import datetime
import urllib2
"""
Use this function to allow applications to communicate via HTTP to the internet
"""
def setProxy():
@alcedo
alcedo / Unix_unix_notes.sh
Created October 10, 2013 08:58
Unix notes
### How to change permissions of all files in a dir using XARGS
[root@abc installers]# ls | xargs -Ifile chmod 777 file
[root@abc installers]# ls -rlt
total 446676
-rwxrwxrwx 1 abc abc 30537780 Oct 8 08:18 hcatalog-0.11.0.1.3.2.0-111.tar.gz
-rwxrwxrwx 1 abc abc 14492759 Oct 8 08:20 Python-2.7.5.tgz
[root@abc installers]# ls | xargs -I{} chmod 777 {}
@alcedo
alcedo / 0_reuse_code.js
Created October 10, 2013 08:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console