Skip to content

Instantly share code, notes, and snippets.

View NateJLewis's full-sized avatar
🎯
Focusing

Nate Lewis NateJLewis

🎯
Focusing
View GitHub Profile
@incredimike
incredimike / variousCountryListFormats.js
Last active May 8, 2024 15:54
List of Countries in various Javascript data structures: Alphabetical country lists & Country data objects.
// Lists of countries with ISO 3166 codes, presented in various formats.
// Last Updated: July 30, 2020
// If you're using PHP, I suggest checking out:
// https://github.com/thephpleague/iso3166
// or Laravel: https://github.com/squirephp/squire
//
// JS developers can check out:
// https://www.npmjs.com/package/iso3166-2-db
//
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@lsauer
lsauer / gist:2757250
Last active October 10, 2022 03:06
JavaScript : within a string, count the number of occurances of a character / character counting and string-position
//www.lsauer.com 2012
//Answer to:
//http://stackoverflow.com/questions/881085/count-the-number-of-occurances-of-a-character-in-a-string-in-javascript/10671743#10671743
//There are at least four ways. The best option, which should also be the fastest -owing to the native RegEx engine -, is placed at the top. //jsperf.com is currently down, otherwise I would provide you with performance statistics.
#1.
("this is foo bar".match(/o/g)||[]).length
//>2
#2.
"this is foo bar".split("o").length-1
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@briancray
briancray / linkify.js
Created November 6, 2012 13:56
Linkify Twitter API entities
/*
Compliant with Twitter's Developer Display Requirements:
https://dev.twitter.com/terms/display-requirements
*/
var linkify_result = function (tweet /* tweet object from the results array */) {
var subs = [],
last_offset = 0,
new_tweet = '',
entity,
replace = {
@steve-taylor
steve-taylor / doSynchronousLoop.js
Last active December 4, 2022 00:51
Synchronous for loop in JavaScript to ensure that the n+1th item isn't processed until the callback of the nth item's processor has been called.
/**
* Process an array of data synchronously.
*
* @param data An array of data.
* @param processData A function that processes an item of data.
* Signature: function(item, i, callback), where {@code item} is the i'th item,
* {@code i} is the loop index value and {@code calback} is the
* parameterless function to call on completion of processing an item.
*/
function doSynchronousLoop(data, processData, done) {
@jakemmarsh
jakemmarsh / directives.js
Created June 26, 2013 14:18
AngularJS directive to create a functional "back" button
app.directive('backButton', function(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', goBack);
function goBack() {
history.back();
scope.$apply();
@webgurus
webgurus / acf_slider_bootstrap
Last active September 7, 2020 10:39
Root's bootstrap slider example with Advanced Custom Fields Gallery plugin.
<?php
/* SLIDER CUSTOM FIELD FOR HOMEPAGE */
$images = get_field('slider_photos');
$count=0;
$count1=0;
if($images) : ?>
<div id="slider">
<div id="carousel" class="carousel slide">
<!-- Indicators -->
@Shelob9
Shelob9 / ships.php
Last active April 4, 2020 21:25
Example code for my Pods Screencast: Using Pods Pages With Advanced Content Types -- http://youtu.be/iUDPYid0bUU
<?php
/**
* Template Name: Ships
*/
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">