Skip to content

Instantly share code, notes, and snippets.

View danielrobertson's full-sized avatar
☁️

Daniel danielrobertson

☁️
View GitHub Profile
@danielrobertson
danielrobertson / isPalindrome.java
Created September 22, 2015 01:44
Return true if the string is palindrome, false otherwise
boolean isPalindrome(String s) {
for(int front = 0, end = s.length() - 1; front <= end; front++, end--) {
if(s.charAt(front) != s.charAt(end)) {
return false;
}
}
return true;
}
@danielrobertson
danielrobertson / NumberOfPalindromicSubstrings.java
Last active September 22, 2015 01:42
Given a string, print the number of palindromic substrings
/**
* Created by daniel robertson on 9/6/15.
*/
import java.io.*;
import java.util.*;
import java.lang.StringBuffer;
public class NumberOfPalindromicSubstrings {
static int palindrome(String str) {
int result = 0;
class Multiton {
static HashMap<String, Multiton> map = new HashMap<String, Multiton>();
private Multiton(String key) { ... }
static Multiton newMultion(String key) {
result = map.get(key);
if(result == null) {
result = new Multiton(key);
map.add(key, result);
@danielrobertson
danielrobertson / .gitconfig
Last active June 12, 2021 22:26
.gitconfig
[user]
name = Daniel Robertson
email = [email protected]
[alias]
p = pull
a = add
st = status
ci = commit
br = branch
@danielrobertson
danielrobertson / RemoveDuplicates.py
Created March 19, 2015 17:48
Remove duplicates in CSV
import pandas as pd
toclean = pd.read_csv('fileWithDuplicates.csv')
deduped = toclean.drop_duplicates('columnName')
deduped.to_csv('fileWithoutDuplicates.csv')
@danielrobertson
danielrobertson / examplePayload
Created November 12, 2014 00:01
Field Day registration
{
"registration": {
"children": [
{
"firstName": "joe",
"lastName": "bro",
"dob": "11 march 1990"
},
{
"firstName": "jay",
@danielrobertson
danielrobertson / JDBCService
Last active August 29, 2015 14:08
Connect to MySQL with JDBC
// load the MySQL driver. Alternatively, use the Maven http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.33
Class.forName("com.mysql.jdbc.Driver");
// connect to database named openstack_projects on port 3306
String url = "jdbc:mysql://localhost:3306/openstack_projects";
Connection conn = DriverManager.getConnection(url, "root", "");
// make a query
String sql = "select * from projects";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
@danielrobertson
danielrobertson / intellij.desktop
Last active August 29, 2015 14:01
How to add an icon for IntelliJ. Update the Icon and Exec to where you unzipped idea-IC-135.690.gz and installed IntelliJ.
// create file:
sudo vim /usr/share/applications/intellij.desktop
// add the following
[Desktop Entry]
Version=13.0
Type=Application
Terminal=false
Icon[en_US]=/home/daniel/idea-IC-135.690/bin/idea.png
Name[en_US]=IntelliJ
def z_score(n, l):
mean = sum(l) / len(l)
return (n - mean) / (stddev(l) / math.sqrt(len(l)))