Skip to content

Instantly share code, notes, and snippets.

View cougar999's full-sized avatar

Charles cougar999

  • Melbourne
View GitHub Profile
@cougar999
cougar999 / JS format functions.txt
Last active October 14, 2016 02:31
JS format functions
function fixJsonString(str) {
if (!str) return;
return(str.replace(/(\\u[0-9abcdef]{4})/ig, function(a) { return eval('"' + a + '"'); }));
};
function fixNameString(str) {
if (!str) return;
return(str.replace(/[^.a-zA-Z0-9_\u4e00-\u9fa5\,;。“”:!\/]/ig, ''));
};
@cougar999
cougar999 / calculate Month
Created October 23, 2016 11:00
calculate Month
function add_months($months, DateTime $dateObject)
{
$next = new DateTime($dateObject->format('Y-m-d'));
$next->modify('last day of +'.$months.' month');
if($dateObject->format('d') > $next->format('d')) {
return $dateObject->diff($next);
} else {
return new DateInterval('P'.$months.'M');
}

Day 26 - Galactic Light Trails

Stars and planets shine bright in the everlasting darkness of space. Send them into warp speed via a click and hold.

Was supposed to post yesterday as part of my one pen every two day challenge, but wasn't proud of any of my final products. Creating physics simulations is proving to be a bit harder than I initially thought, but no worries, churning away at the trig and physics books throughout the hours.

More to come.

A Pen by Christopher Lis on CodePen.

@cougar999
cougar999 / # Sublime Emmet JSX Reactjs.md
Created August 21, 2019 05:54 — forked from pbojinov/# Sublime Emmet JSX Reactjs.md
Sublime text 3. Enable Emmet in JSX files with Sublime React plugin

Problem

  • Using emmet in jsx files
  • Emmet expands text when js autocomplete needed
  • Using className instead of class

How it works

  • Install plugin RegReplace
  • Install plugin Chain Of Command