Skip to content

Instantly share code, notes, and snippets.

cur_alpha_str = ""
longest_alpha_str = ""
for letter in s:
if cur_alpha_str == "" or letter > cur_alpha_str[-1]:
cur_alpha_str += letter
else:
if len(cur_alpha_str) > len(longest_alpha_str):
longest_alpha_str = cur_alpha_str
cur_alpha_str = str(letter)
cur_alpha_str = ""
long_alpha_str = ""
for c in s:
if len(cur_alpha_str) == 0 or c >= cur_alpha_str[-1]:
cur_alpha_str += str(c)
else:
if len(cur_alpha_str) > len(long_alpha_str):
long_alpha_str = cur_alpha_str
cur_alpha_str = str(c)
@efuquen
efuquen / gnews-top-stories.js
Created August 18, 2015 02:35
Google News Top Stories Scraper
var request = require('request');
var cheerio = require('cheerio');
request('https://news.google.com/', function(error, response, body) {
if (!error && response.statusCode == 200) {
getTopStories(body);
} else {
console.error(error);
console.error('Status Code: ' + response.statusCode);
}
@efuquen
efuquen / knife-role-node-list
Created April 17, 2012 21:04
Lists all the nodes that fall under a specified role
#!/bin/bash
function search_node {
NODE_ROLES=$(knife node show $1 | grep Roles | grep $2)
if [ "" != "$NODE_ROLES" ]
then
echo "$1"
fi
}
import java.io.*;
//Custom java md5 implementaiton, use whatever you have available, as long as you stream bytes
//into it.
import com.twmacinta.util.MD5;
public class FileHash
{
/*
@efuquen
efuquen / gist:2706664
Created May 16, 2012 01:48
Grooveshark MD5 Calculations
import java.io.*;
//Custom java md5 implementaiton, use whatever you have available, as long as you stream bytes
//into it.
import com.twmacinta.util.MD5;
public class FileHash
{
/*
efuquen@ubuntest ~/Code/oss/libav (master) $ gdb ./avconv
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@efuquen
efuquen / gist:6235987
Last active December 21, 2015 02:38
Will prepend a git commit with a user story number, which conforms to the regex "US[0-9][0-9]*", *if* the currently checked out branch ends in the user story. For example, a branch called "some-branch-name-US1234" will have all git commits starting with "US1234 - Some git commit message here". If you are in a branch that does not end in User Sto…
#!/bin/bash
CURRENT_BRANCH="$(git symbolic-ref HEAD | awk -F '\/' '{ print $NF }')"
if [[ $CURRENT_BRANCH =~ ^.*US[0-9][0-9]*$ ]]; then
STORY_ID="$(echo $CURRENT_BRANCH | sed 's/^.*\(US[0-9][0-9]*\)$/\1/')"
cat $1 | awk '{if(NR == 1) { print "'${STORY_ID}' -",$0 } else { print $0 } }' > $1.tmp
mv $1.tmp $1
fi
mport csv
import locale
import sys
locale.setlocale(locale.LC_ALL, '')
csv_filepath = sys.argv[1]
winners = []
with open(csv_filepath, 'rb') as csvfile:
" Installs vim-plug.
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'