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
console.info('Hello');
@phucpnt
phucpnt / move-cra-build-static-folder.js
Last active November 20, 2018 03:38
Create react app - build script for moving "build" and "static" folder to another location
const fs = require("fs-extra");
const path = require("path");
const klaw = require("klaw");
const through2 = require("through2");
function run(newBuildFolder = "./dist", staticFolderName = "statiz") {
fs.remove("./dist").then(() =>
fs.copy("./build", newBuildFolder).then(() => {
const updateFolderBuildFile = through2.obj(function(item, enc, next) {
if (/\.(js|css|json|html)$/.test(path.extname(item.path))) {
@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 / 01-console.log
Last active December 18, 2017 15:27
Uniforms: react-hot-loader/babel. Issue with getModel on `BaseForm`
BaseForm.js:53 Uncaught ReferenceError: getModel is not defined
at AutoValidatedQuickAntDForm.__getModel__REACT_HOT_LOADER__ (BaseForm.js:53)
at AutoValidatedQuickAntDForm.BaseForm._this.getModel (BaseForm.js:44)
at AutoValidatedQuickAntDForm.getChildContextModel (BaseForm.js:84)
at AutoValidatedQuickAntDForm.getChildContext (BaseForm.js:63)
at processChildContext (react-dom.development.js:5456)
at invalidateContextProvider (react-dom.development.js:5506)
at finishClassComponent (react-dom.development.js:7889)
at updateClassComponent (react-dom.development.js:7850)
at beginWork (react-dom.development.js:8225)
@phucpnt
phucpnt / .babelrc
Last active September 12, 2016 16:24
Es6 (babel) boilerplate with eslint airbnb base
{
"presets": [
"es2015",
"react"
]
}
@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);
};