Skip to content

Instantly share code, notes, and snippets.

View DrCord's full-sized avatar

Cord Slatton DrCord

View GitHub Profile
@kevboutin
kevboutin / vindecoder.js
Last active April 23, 2024 11:09
Decode a VIN
/**
* VIN decoder.
*
* kevinboutin on 3/11/18.
*
* My VIN for testing is WBA3A5G59DNP26082 so use the following command to invoke:
* node vindecoder WBA3A5G59DNP26082
*
* Examples:
* KM8JM12D56U303366
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@mickdekkers
mickdekkers / SnapshotCamera.cs
Last active March 8, 2024 19:02
Take snapshot images of Prefabs and GameObjects in Unity using Render Textures
using UnityEditor;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
// Object rendering code based on Dave Carlile's "Create a GameObject Image Using Render Textures" post
// Link: http://crappycoding.com/2014/12/create-gameobject-image-using-render-textures/
@brianmacarthur
brianmacarthur / flash-app.js
Last active July 10, 2023 18:41
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@mikeatlas
mikeatlas / gist:0b69b354a8d713989147
Last active August 30, 2017 17:53
splitting polyline paths across the international dateline in leaflet (sorry that it uses a mix of jQuery and lo-dash for helpers and is in coffeescript)
Array.prototype.splitAtEvery = (callback) ->
sections = []
arrayClone = this.slice(0)
$.each(arrayClone, (idx, item) =>
sectionsLength = 0
_.each(sections, (section) =>
sectionsLength += section.length;
)
if callback(this, idx, item) == true
sections.push(arrayClone.slice(0, idx+1-sectionsLength))
@builtbylane
builtbylane / angular-remove-white-space-filter.js
Created October 30, 2013 18:43
AngularJS – filter: removes white space from text. useful for html values that cannot have spaces
/**
* Description:
* removes white space from text. useful for html values that cannot have spaces
* Usage:
* {{some_text | nospace}}
*/
app.filter('nospace', function () {
return function (value) {
return (!value) ? '' : value.replace(/ /g, '');
@calvinchoy
calvinchoy / PHP - ip and bigint converter.php
Created June 20, 2013 08:38
PHP - ip and bigint converter
<?php
//Helper function to convert bigint to ip adress
function int2ip($intip){
$ipVal = $intip;
$ipArr = array(0 => floor($ipVal/0x1000000) );
$ipVint = $ipVal-($ipArr[0]*0x1000000); // for clarity
$ipArr[1] = ($ipVint & 0xFF0000) >> 16;
$ipArr[2] = ($ipVint & 0xFF00 ) >> 8;
$ipArr[3] = $ipVint & 0xFF;
$ipDotted = implode('.', $ipArr);
@liorkesos
liorkesos / File Stucture
Last active December 17, 2015 01:28
A sequence of files which get called and enable an angular.js app The app structure looks like this
app
index.html
app.js
css/
js/
controllers/
youtubeSearch.js
services/
views/
main.html
@MichalPekala
MichalPekala / .bash_profile
Last active May 17, 2017 21:45
Raspberry Pi .bash_profile
#!/bin/bash
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
@netsensei
netsensei / drupal-ajax.php
Created November 7, 2012 11:14
Minimal Drupal Bootstrap for AJAX requests
<?php
/**
* @file
*
* Minimal AJAX page. Call like this:
* $.ajax({
* type: 'GET',
* url: '/drupal-ajax.php?param1=...
* data: {},