Skip to content

Instantly share code, notes, and snippets.

// https://inkplant.com/code/ipv6-to-number
<?php
function ipaddress_to_ipnumber($ipaddress) {
$pton = @inet_pton($ipaddress);
if (!$pton) { return false; }
$number = '';
foreach (unpack('C*', $pton) as $byte) {
$number .= str_pad(decbin($byte), 8, '0', STR_PAD_LEFT);
}
// https://inkplant.com/code/get-timezone
<?php
function get_timezone($latitude,$longitude,$username) {
//error checking
if (!is_numeric($latitude)) { custom_die('A numeric latitude is required.'); }
if (!is_numeric($longitude)) { custom_die('A numeric longitude is required.'); }
if (!$username) { custom_die('A GeoNames user account is required. You can get one here: http://www.geonames.org/login'); }
<?php
$formaction = $_SERVER['PHP_SELF']; //the URL the form should send users to on submit
$allowedfiletypes = array('csv'); //a comma separated list of allowed extensions
$uploadfolder = './'; //the folder where the uploaded file should be moved to
$uploadfilename = 'data.csv'; //the filename that the uploaded file should be renamed to
//check to see if the form has been submitted
if (array_key_exists('action',$_POST) && is_string($_POST['action']) && (strip_tags($_POST['action']) == 'upload')) { //the form has been submitted
echo '<p>Uploading file... ';
if (empty($_FILES['uploadfile']['name'])) {
/**
* Convert data in CSV (comma separated value) format to a javascript array.
*
* Values are separated by a comma, or by a custom one character delimeter.
* Rows are separated by a new-line character.
*
* Leading and trailing spaces and tabs are ignored.
* Values may optionally be enclosed by double quotes.
* Values containing a special character (comma's, double-quotes, or new-lines)
<?php
// TSV to Array Function
// Copyright (c) 2015, Ink Plant
// https://inkplant.com/code/
// this version was last updated June 23, 2015
function tsv_to_array($file,$args=array()) {
//key => default
$fields = array(
@samjaninf
samjaninf / to_array.js
Created September 26, 2018 18:36 — forked from pcbje/to_array.js
Convert tabular text (csv, tsv, etc.) to javascript array
var to_array = function(text, delimeter, has_header, header_size) {
var lines = text.split('\n');
var columns = has_header ? lines[header_size - 1].split(delimeter) : null;
var rows = [];
for (var i=header_size; i<lines.length; i++) {
var array = lines[i].split(delimeter);
var row = {};
for (var j in array) {
@samjaninf
samjaninf / The Technical Interview Cheat Sheet.md
Created September 26, 2018 01:08 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
#### Exercises
1. Define and compare recursion and iteration.
Recursion is a procedure that calls itself until a certain condition (base case) is reached. Recursive solutions can be slower and are subjected to system limitations
Iteration is a procedure that uses loop to repeat a process. Iterative solutions may be harder to implement.
2. Name five algorithms that are commonly implemented by recursion.
@samjaninf
samjaninf / install odoo 11 centos
Last active November 19, 2018 20:56
install odoo 11 centos
cd ~
adduser --system --shell=/bin/bash --home-dir=/opt/odoo --user-group odoo
yum -y groupinstall "development tools"
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install python36u python36u-pip python36u-devel wget unzip postgresql-devel npm nodejs git libjpeg-devel libxml2-devel libxslt-devel openldap-devel cyrus-sasl-devel
pip3.6 install --upgrade pip
ln -s /usr/bin/python3.6 /usr/bin/python3
wget -nc https://github.com/odoo/odoo/archive/11.0.zip -O archive.zip
unzip -nq archive.zip
mkdir -p /opt/odoo
server {
listen 80;
listen 443 ssl http2;
server_name your.mautic.location;
root /your/mautic/path ;
server_tokens off;
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';