Skip to content

Instantly share code, notes, and snippets.

@phucpnt
phucpnt / classify.py
Created July 30, 2020 00:51 — forked from bwbaugh/classify.py
Detecting a Specific Watermark in a Photo with Python Get example training and testing images here: <http://bwbaugh.com/stack-overflow/16222178_watermark.tar> Stack Overflow question: <http://stackoverflow.com/questions/16222178/detecting-a-specific-watermark-in-a-photo-with-python-without-scipy>
# Copyright (C) 2013 Wesley Baugh
"""Tools for text classification.
Extracted from the [infer](https://github.com/bwbaugh/infer) library.
"""
from __future__ import division
import math
from collections import defaultdict, namedtuple, Counter
from fractions import Fraction
@phucpnt
phucpnt / multipart.js
Created July 12, 2018 08:55 — forked from dcollien/multipart.js
Parse multi-part formdata in the browser
var Multipart = {
parse: (function() {
function Parser(arraybuf, boundary) {
this.array = arraybuf;
this.token = null;
this.current = null;
this.i = 0;
this.boundary = boundary;
}
@phucpnt
phucpnt / linode-security.md
Created September 3, 2016 16:58 — forked from eliangcs/linode-security.md
Basic security setup for a brand new Linode

Basic Security Setup for a Brand New Linode

Why

When you start a clean Linode, it isn't secured in the following aspects:

  • Allows root SSH login
  • Uses password authentication on SSH
  • Doesn't have a firewall
@phucpnt
phucpnt / .jsbeautifyrc
Created August 18, 2016 02:08 — forked from softwarespot/.jsbeautifyrc
JS Beautifier configuration
// Documentation: https://github.com/beautify-web/js-beautify
// Example URL: https://github.com/victorporof/Sublime-HTMLPrettify/blob/master/.jsbeautifyrc
// Based on Airbnb's JavaScript Style Guide, URL: https://github.com/airbnb/javascript
{
// Collapse curly brackets
"brace_style": "collapse",
// Break chained method calls across subsequent lines
"break_chained_methods": true,
@phucpnt
phucpnt / requireNoCache.js
Created July 9, 2016 02:36 — forked from adam-lynch/requireNoCache.js
Require a module, without going to Node.js's require cache
var path = require('path');
var _invalidateRequireCacheForFile = function(filePath){
delete require.cache[path.resolve(filePath)];
};
var requireNoCache = function(filePath){
_invalidateRequireCacheForFile(filePath);
return require(filePath);
};
@phucpnt
phucpnt / index.html
Created May 16, 2016 21:31 — forked from mhkeller/index.html
Sample d3 gantt chart, sorting works, filtering broken
<title>Ganttttttttttttt</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
<style>
.axis path,
.axis line {
fill: none;
stroke: none;
shape-rendering: crispEdges;
<?php
//Automatically login a single WordPress user upon arrival to a specific page.
//Redirect to home page once logged in and prevent viewing of the login page.
//Tested with WP 3.9.1. Used in functions.php
//Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead."
//From http://tourkick.com/2014/wordpress-demo-multisite-db-reset/
function auto_login() {
//change these 2 items
$loginpageid = '1234'; //Page ID of your login page
@phucpnt
phucpnt / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@phucpnt
phucpnt / repair.php
Created February 26, 2014 09:58 — forked from chicks/repair.php
#! /usr/bin/env php
<?php
# Stuff we have to do
if(!defined('sugarEntry'))define('sugarEntry', true);
function usage() {
global $argv;
return "\n" . $argv[0] . " <path to sugar>\n";
}