This file contains 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
# Java Maven CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-java/ for more details | |
# | |
version: 2 | |
jobs: | |
build: | |
docker: | |
# specify the version you desire here | |
- image: circleci/openjdk:8-jdk |
This file contains 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
parent_index = lambda x: (x - 1) / 2 | |
left_child_index = lambda x: 2 * x + 1 | |
def heapsort(arr): | |
""" | |
sorts the given list using heapsort | |
""" | |
heapify(arr) | |
print_heap(arr) | |
sort_heap(arr) |
This file contains 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
# A side-step solution because I was too lazy to find the repeated word... | |
# It find the most common letter, but exclude ' ', which is the lowest value and is often more common than 'e' | |
import sys | |
from collections import Counter | |
with open(sys.argv[1], 'r') as test_cases: | |
for test in test_cases: | |
vals = map(int, test.split('|')[2].strip().split(' ')) | |
m = min(vals) | |
e = Counter(v for v in vals if v != m).most_common(1)[0][0] |
This file contains 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
from collections import Counter | |
size = 11 | |
tab = [None] * size*size | |
def split(t): | |
return [t[size*i:size*i+size] for i in range(size)] | |
def splitV(t): |
This file contains 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 android.net.Uri; | |
import android.test.InstrumentationTestCase; | |
import java.io.UnsupportedEncodingException; | |
import java.net.URLEncoder; | |
public class UriTest extends InstrumentationTestCase { | |
public void testQueryParameters() throws UnsupportedEncodingException { | |
Uri uri = Uri.parse("http://domain.com/test?single_value=1"); |
This file contains 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 itertools | |
letters = "acdegilmnoprstuw" | |
value = 25180466553932 | |
def hsh(s): | |
return reduce(lambda h, char: h * 37 + letters.index(char), s, 7) | |
def unhash(val): | |
return unhash(val / 37) + letters[val % 37] if val > 7 else '' |
This file contains 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
source ~/git-completion.bash | |
source ~/git-prompt.sh | |
export RES='$(if [[ $? = 0 ]]; then echo -e "\e[0;32m\xe2\x9c\x94\e[m"; else echo -e "\e[0;31m\xe2\x9c\x98\e[m"; fi;)' | |
export PS1="$RES \e[1;36m\t\e[m\e[0;33m(\u)\e[m\e[40m\e[37m\w\e[m\e[1;35m\$(__git_ps1)\e[m\n\$ " | |
alias l='ls' | |
alias ll='ls -l' | |
alias less='less -N' |
This file contains 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
private static final String SNAPR_URL = "http://sna.pr/api/search/"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, | |
android.R.layout.simple_list_item_1); | |
setListAdapter(adapter); | |
new Downloader(adapter).execute(SNAPR_URL); | |
} |
This file contains 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
for (int i = 0; i < images.length(); i++) { | |
JSONObject object = images.optJSONObject(i); | |
if (object != null) { | |
mAdapter.add(object.optString("description")); | |
} | |
} |
This file contains 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
JSONObject response = new JSONObject(EntityUtils.toString( | |
new DefaultHttpClient().execute( | |
new HttpGet(params[0])).getEntity(), "UTF-8")); | |
if (response.optBoolean("success", false)) { | |
return response.getJSONObject("response").getJSONArray("photos"); | |
} else { | |
Log.w(TAG, "Request failed. Details: " + response.toString(2)); | |
} |
NewerOlder