Skip to content

Instantly share code, notes, and snippets.

@habedi
habedi / nltk-intro.py
Created December 14, 2017 08:52 — forked from alexbowe/nltk-intro.py
Demonstration of extracting key phrases with NLTK in Python
import nltk
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""
# Used when tokenizing words
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.
@habedi
habedi / useful_pandas_snippets.py
Created August 19, 2017 07:22 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@habedi
habedi / Makefile
Created August 8, 2017 15:02 — forked from informationsea/Makefile
Makefile template
# Hey Emacs, this is a -*- makefile -*-
# Copyright (C) 2013 Y.Okamura
# https://gist.github.com/2343121
# MIT License
# Target Executable file
TARGET = exefile
# C source code
SRC =
from __future__ import division
from sklearn.cluster import KMeans
from numbers import Number
from pandas import DataFrame
import sys, codecs, numpy
class autovivify_list(dict):
'''Pickleable class to replicate the functionality of collections.defaultdict'''
def __missing__(self, key):
value = self[key] = []
@habedi
habedi / LDIFGenerator.java
Created July 28, 2017 17:12 — forked from hasithaa/LDIFGenerator.java
A LDIF Generator Utill
/**
* Copyright (c) 2014.
* This file is licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
@habedi
habedi / nngarotte.py
Created July 17, 2017 19:15 — forked from agramfort/nngarotte.py
Non Negative Garotte
"""
Non-Negative Garotte implementation with the scikit-learn
"""
# Author: Alexandre Gramfort <[email protected]>
# Jaques Grobler (__main__ script) <[email protected]>
#
# License: BSD Style.
import numpy as np
@habedi
habedi / postJSON.cs
Created June 2, 2017 15:42 — forked from manuerumx/postJSON.cs
Unity 3D example POST JSON Data to a Server with http Auth
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class goLevel : MonoBehaviour {
//With the @ before the string, we can split a long string in many lines without getting errors
private string json = @"{
'hello':'world',
'foo':'bar',
'count':25
@habedi
habedi / remove_emoji.py
Created May 16, 2017 18:36 — forked from jinstrive/remove_emoji.py
python remove emoji in string
def remove_emoji(data):
"""
去除表情
:param data:
:return:
"""
if not data:
return data
if not isinstance(data, basestring):
return data
@habedi
habedi / README.md
Created May 12, 2017 08:08 — forked from janeczku/README.md
Batch delete those unused stale forked repositories in your Github account

Cleaning up your Github account from those repositories you once forked and then forgot about is a tedious process when done manually.

Lets speed up this process with some automagic:

  1. Open all repositories that you want to delete in new browser tabs
  2. Use https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall?hl=en to shorten them to a list and export the URL's as a text file
  3. In a text editor shorten the URL's to just the last part (username/repositoryname)
  4. Create a new personal API token with capability to delete repositories and paste that token in the script
  5. Run ./clean-repos.sh
@habedi
habedi / README.md
Created April 16, 2017 09:52 — forked from mrkpatchaa/README.md
Bulk delete github repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.