Skip to content

Instantly share code, notes, and snippets.

@ollien
ollien / CAH.py
Last active August 29, 2015 14:07
Cards Against humanity PyIRCBot Module
#!/usr/bin/env python
from modulebase import ModuleBase,ModuleHook
# import random
import yaml
import os
import time
from threading import Timer
from operator import itemgetter
from random import choice
@ollien
ollien / example.java
Created November 20, 2014 05:08
Read Files with Java
try{
BufferedReader reader = new BufferedReader(new FileReader("fileName.txt"));
String line = "";
while ((line = reader.readLine())!=null){
//Do something with the line, say store it in an array
}
reader.close();
}
catch (FileNotFoundException e){
e.printStackTrace();
@ollien
ollien / main.java
Created December 14, 2014 04:31
Twitter Percent Encode
private static String percentEncode(String s){
String result = "";
for (int i=0; i<s.length(); i++){
char check = s.charAt(i);
if (Character.isLetter(check) || Character.isDigit(check) || check == '-' || check=='.' || check=='_' || check == '~' ){
result+=check;
}
else{
result+=("%"+Integer.toHexString(check));
}
@ollien
ollien / draw.java
Last active August 29, 2015 14:12
Draw Circular Bitmap
Bitmap profileBitmap = BitmapFactory.decodeStream(connection.getInputStream());
Bitmap finalBitmap = Bitmap.createBitmap(profileBitmap.getWidth(),profileBitmap.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(finalBitmap);
Path p = new Path();
p.addCircle(profileBitmap.getHeight()/2,profileBitmap.getHeight()/2,profileBitmap.getWidth()/2,Path.Direction.CCW);
canvas.clipPath(p);;
canvas.drawBitmap(profileBitmap,new Rect(0,0,profileBitmap.getHeight(),profileBitmap.getWidth()),new Rect(0,0,profileBitmap.getHeight(),profileBitmap.getWidth()),null);
@ollien
ollien / gist:2ac102422fe0d101bd8f
Created January 22, 2015 06:43
Convert CSS transition-duration to ms
function timeStringtoTime(s){
if (s.indexOf('ms')!=-1){
var result = s.replace('ms','');
console.log(result);
return parseInt(result);
}
else{
var result = s.replace('s','');
return parseFloat(result)*1000;
}
@ollien
ollien / main.c
Created February 26, 2015 04:36
2/25/15 Homework
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
void forkAndCalculate(int num);
int main(int argc, char **argv){
if (argc!=2 || argv[1]<0){
@ollien
ollien / gist:c271ea7278a1c0b36acf
Created March 27, 2015 18:58
fragment View example
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState){
final View view = inflater.inflate(R.layout.fragment_timeline,viewGroup,false);
final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout)view.findViewById(R.id.refresh);
ListView timelineView = (ListView) view.findViewById(R.id.timelineList);
//...
return view
}
@ollien
ollien / pew.py
Created September 1, 2015 04:53
Pew
import random
import time
from termcolor import cprint
colors = ["grey", "red", "green", "yellow", "blue", "magenta", "cyan", "white"]
while True:
tempColors = list(colors)
foreground = random.choice(tempColors)
tempColors.remove(foreground)
@ollien
ollien / SassMeister-input.scss
Created November 14, 2015 00:58
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$black-color: #191919;
$highlight-color: #469FB3;
html, body {
width: 100%;
height: 100%;
}
@ollien
ollien / SassMeister-input.scss
Created November 14, 2015 22:24
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$black-color: #191919;
$highlight-color: #469FB3;
html, body {
width: 100%;
height: 100%;
}