Skip to content

Instantly share code, notes, and snippets.

View naeluh's full-sized avatar
🌐
Busy

nick hulea naeluh

🌐
Busy
View GitHub Profile
// Keep a reference available throughout the code
var touch = null;
// Called when the document has loaded
// You may choose some other place to do this
// Needs to occur only once
function doLoad()
{
var element = null;
<?php
/**
* Sends a simple email.
* [or] Tested on 2012-05-31 using Drupal 7.12
*
* Usage:
* 1) Paste all the below code into your module or include
* 2) Configure the two @FIXME's.
* 3) Visit /_custom_simple_mail to get an email.
*
@naeluh
naeluh / csv-to-json.php
Last active August 29, 2015 14:27 — forked from robflaherty/csv-to-json.php
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@naeluh
naeluh / template.html
Created October 9, 2015 18:10 — forked from tinabeans/template.html
A super-barebones single-column responsive email template, assuming a max-width of 540px. Read about it on the Fog Creek blog.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@naeluh
naeluh / trim.string.js
Created October 16, 2015 17:44 — forked from pbojinov/trim.string.js
Shorten string to specified max length and and append ... at the end. It will not cut in the middle of a word but at the minimum amount of words under the limit.
function trim(message, maxLength) {
var m = message;
var maxLen = maxLength;
//string is too long, lets trim it and append ...
if (m.length > maxLen) {
var lastSpace = m.lastIndexOf(' ');
//there is no space in the word
if (lastSpace === -1) {
m = m.slice(0, maxLen-3);
@naeluh
naeluh / get_color_code.py
Created July 22, 2016 00:04 — forked from jayapal/get_color_code.py
get_color_code.py
from sklearn.cluster import KMeans
from sklearn import metrics
import cv2
# By Adrian Rosebrock
import numpy as np
import cv2
# Load the image
image = cv2.imread("red.png")
@naeluh
naeluh / autop.php
Created September 23, 2016 16:24 — forked from joshhartman/autop.php
Function to automatically add paragraphs to blocks of text with line breaks, ripped from WordPress
<?php
/**
* Replaces double line-breaks with paragraph elements.
*
* A group of regex replaces used to identify text formatted with newlines and
* replace double line-breaks with HTML paragraph tags. The remaining
* line-breaks after conversion become <<br />> tags, unless $br is set to '0'
* or 'false'.
*
* @param string $pee The text which has to be formatted.
@naeluh
naeluh / README.md
Created March 30, 2017 22:00 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@naeluh
naeluh / setup.md
Created January 2, 2018 18:19 — forked from xrstf/setup.md
Nutch 2.3 + ElasticSearch 1.4 + HBase 0.94 Setup

Info

This guide sets up a non-clustered Nutch crawler, which stores its data via HBase. We will not learn how to setup Hadoop et al., but just the bare minimum to crawl and index websites on a single machine.

Terms

  • Nutch - the crawler (fetches and parses websites)
  • HBase - filesystem storage for Nutch (Hadoop component, basically)
@naeluh
naeluh / package.json
Created April 20, 2018 16:59 — forked from surma/package.json
Boilerplate for quick one-off TypeScript projects. Just run `npm start`
{
"name": "tsquickstart",
"version": "1.0.0",
"description": "Boilerplate for quick one-off TypeScript projects. Just run `npm start`",
"scripts": {
"init": "test -f tsconfig.json || (tsc --init -t ESNext -m ESNext && npm install)",
"start": "npm run init && concurrently \"npm run watch\" \"npm run serve\"",
"serve": "http-server",
"watch": "tsc -p . --watch",
"build": "tsc -p ."