Skip to content

Instantly share code, notes, and snippets.

@kaanuki
kaanuki / .htaccess
Created July 10, 2017 12:17 — forked from mreidsma/.htaccess
Simple click tracking script
// .htaccess
//
// Add this to the directory where your write.php will be stored
// This is an easy way to do an HTTP request to the script with the data
<IfModule mod_rewrite.c>
RewriteEngine On
# Change the following to the base directory of this file
RewriteBase /clickstats/
@kaanuki
kaanuki / loadCSV.php
Created May 15, 2017 15:41 — forked from josephspurrier/loadCSV.php
Parse a CSV file in PHP, remove hidden characters, escape fields to prepare for MySQL, and return an associative array.
// Auto detect line endings
ini_set('auto_detect_line_endings', true);
function loadCSV($file)
{
// Create an array to hold the data
$arrData = array();
// Create a variable to hold the header information
$header = NULL;
@kaanuki
kaanuki / py2php.py
Created March 13, 2017 12:27 — forked from reusee/py2php.py
Python to php translator, compile python script to php
import ast
from cStringIO import StringIO
import sys
INFSTR = '1e308'
def interleave(inter, f, seq):
seq = iter(seq)
try:
f(next(seq))
@kaanuki
kaanuki / gist:5c82cdfb0f18c4606f1f4f45190ce3a0
Created December 19, 2016 19:18
scrapy yellowpages spider
from scrapy.spider import Spider
from scrapy.selector import Selector
from yp.items import YpItem
class YpSpider(Spider):
name = "yp"
allowed_domains = ["yellowpages.com"]
start_urls = [
"http://www.yellowpages.com/ft-worth-tx/churches?g=ft.%20worth%2C%20tx&q=churches"
]
<!doctype>
<html>
<head>
</head>
<body>
<?php
require_once "Classes/PHPExcel.php";
$tmpfname = "test.xlsx";
@kaanuki
kaanuki / read-write-file.js
Created November 28, 2016 13:07
Read Write to file with javascript
/// write to file
var txtFile = "c:/test.txt";
var file = new File(txtFile);
var str = "My string of text";
file.open("w"); // open file with write access
file.writeln("First line of text");
file.writeln("Second line of text " + str);
file.write(str);
file.close();
@kaanuki
kaanuki / spin.js
Created July 25, 2016 23:22 — forked from irazasyed/spin.js
JavaScript: Text Spinner Function
/* ============================================================
| :=Text Spinner
=============================================================== */
function preg_quote(str, delimiter) {
return (str + '').replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&');
}
function spin(text) {
var matches = text.match(/{[^<]+/gi);
if (matches === null) {
@kaanuki
kaanuki / WiFiCheck
Created May 7, 2016 12:01 — forked from mharizanov/WiFiCheck
Script to check and re-connect WiFi on Raspberry Pi
#!/bin/bash
##################################################################
# A Project of TNET Services, Inc
#
# Title: WiFi_Check
# Author: Kevin Reed (Dweeber)
# [email protected]
# Project: Raspberry Pi Stuff
#
# Copyright: Copyright (c) 2012 Kevin Reed <[email protected]>