Skip to content

Instantly share code, notes, and snippets.

View newtonmwai's full-sized avatar

Mwai Newton newtonmwai

  • Chalmers University of Technology
  • Gothenburg, Sweden
  • X @mwai_newton
View GitHub Profile
@newtonmwai
newtonmwai / crack.py
Created April 2, 2019 16:47 — forked from hrickards/crack.py
Files for cracking substitution ciphers.
#!/usr/bin/pypy
# Change the above #! if you want to use python (slower) rather than pypy
import random, re, sys, math
from segment import segment
# Usage: ./crack.py ciphertext
# where ciphertext is (you guessed it) a plaintext file containing the
# ciphertext
@newtonmwai
newtonmwai / SKhelper.py
Created April 1, 2019 18:51 — forked from powerlim2/SKhelper.py
This module is to ease your analysis with Scikit_Learn in Python. It gives a few functionalities that the current Scikit_Learn library does not offer. Please free to download and use it.
# coding=UTF8
#########################################################################
# This class is to help sklearn to handle statistical process #
# Author: Joon Lim from Master of Science in Analytics at Northwestern #
# Date: 04.23.2013 #
#########################################################################
''' this Module is built on top of numpy and sklearn. '''
@newtonmwai
newtonmwai / watermarker
Created July 9, 2017 10:41 — forked from umrashrf/watermarker
How to watermark text over images using Python with PIL
#!/usr/bin/python
__author__ = 'umair'
FONTS = (
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf",
"/usr/share/fonts/truetype/droid/DroidSerif-Regular.ttf",
"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
"/home/umair/Downloads/Dosis/Dosis-ExtraBold.ttf"
)
@newtonmwai
newtonmwai / twitrend
Created March 17, 2017 19:00 — forked from urschrei/twitrend
retrieve trending topics from a WOEID location
#!/usr/bin/env python
# encoding: utf-8
"""
twitrend.py
"""
import sys
import os
import tweepy
@newtonmwai
newtonmwai / grab_pdfs.py
Created March 11, 2017 14:18 — forked from elssar/grab_pdfs.py
Download all the pdf files linked in a given webpage.
#!/usr/bin/env python
"""
Download all the pdfs linked on a given webpage
Usage -
python grab_pdfs.py url <path/to/directory>
url is required
path is optional. Path needs to be absolute
@newtonmwai
newtonmwai / example1.py
Created November 22, 2016 13:44 — forked from onyxfish/example1.py
Basic example of using NLTK for name entity extraction.
import nltk
with open('sample.txt', 'r') as f:
sample = f.read()
sentences = nltk.sent_tokenize(sample)
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences]
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True)
public static void postNewComment(Context context,final UserAccount userAccount,final String comment,final int blogId,final int postId){
mPostCommentResponse.requestStarted();
RequestQueue queue = Volley.newRequestQueue(context);
StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
mPostCommentResponse.requestCompleted();
}
}, new Response.ErrorListener() {
@Override