Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@phyous
phyous / BingTranslatorExample.java
Last active February 18, 2018 22:07
Example call to bing translation api in java.
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class ExampleTranslation {
public static void main(String[] args) throws Exception {
//Replace client_id and client_secret with your own.
Translate.setClientId("CLIENT_ID_HERE");
Translate.setClientSecret("CLIENT_SECRET_HERE");
// Translate an english string to spanish
@phyous
phyous / install_simple_pretty_print.sh
Last active June 29, 2017 12:12
A script to enable simple pretty printing of json data.
# Add alias to bash shell
echo "alias json='python -mjson.tool'" >> ~/.bashrc
# Add alias for zsh shell
echo "alias json='python -mjson.tool'" >> ~/.zshrc
@phyous
phyous / MinHopsNovel.java
Last active October 27, 2016 05:43
Calculating Minimum number of hops through an array
import java.util.ArrayList;
import java.util.List;
public class MinHopsNovel {
public static List<Integer> minHops(List<Integer> input) {
List<Integer> ret = new ArrayList<>();
if (input.size() == 0) return ret;
@phyous
phyous / Cib.java
Created July 20, 2016 19:22
Chained interface builder with inheritance
package com.phyous.cib;
public class Cain {
public static void main(String[] args) {
B b = new B.Builder().
parent(
new A.Builder()
.m1(1)
.m2(2)
@phyous
phyous / wpa_supplicant.conf
Created December 16, 2012 00:46
proper config for raspberry pi File: /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="__SSID__"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="__PASSWORD__"
@phyous
phyous / BingOauth.java
Created March 4, 2013 00:32
Sample code for retrieving an Oauth token for use with Bing translation APIs. http://msdn.microsoft.com/en-us/library/ff512421.aspx
import java.io.InputStreamReader;
import java.net.URI;
import java.util.List;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.io.CharStreams;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
@phyous
phyous / gist:7983685
Created December 16, 2013 07:56
The world's simplest twitter client
#!/usr/bin/env ruby
########################
# The world's simplest twitter client
# 1- Get an API key form https://dev.twitter.com with read/write access, enter details below @'ENTER_HERE'
# 2- gem install twitter
# 3- ./post
# 4- Start posting
########################
require "rubygems"
#! /bin/bash
IFS="
"
echo
for FRAME in \
" B :^)" \
" B :^)" \
" B :^)" \
" B :^)" \
final ImageView image = (ImageView) findViewById(R.id.imageview_to_animate);
Animation rotate = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_picture);
image.startAnimation(rotate);