Skip to content

Instantly share code, notes, and snippets.

View nwaughachukwuma's full-sized avatar
🧶
Making stuff

Chukwuma Nwaugha nwaughachukwuma

🧶
Making stuff
View GitHub Profile
@achavez
achavez / gist:9767499
Created March 25, 2014 17:59
Post to Slack using javascript
var url = // Webhook URL
var text = // Text to post
$.ajax({
data: 'payload=' + JSON.stringify({
"text": text
}),
dataType: 'json',
processData: false,
type: 'POST',
url: url
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@samueleaton
samueleaton / poorMansLodash.js
Last active February 13, 2020 23:14
Some basic functionality you would find with lodash
/* eslint-disable id-blacklist */
/* eslint-disable id-length */
/* eslint-disable no-param-reassign */
/* eslint-disable no-implicit-coercion */
/* eslint-disable no-undefined */
/* eslint-disable no-empty-function */
/* eslint-disable semi */
/* eslint-disable quotes */
/* eslint-disable no-eq-nullg */
@tomysmile
tomysmile / mac-setup-redis.md
Last active April 11, 2025 18:01
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@harish2704
harish2704 / lodash.get.js
Last active February 21, 2025 08:14
Simple lodash.get function in javascript
/* Implementation of lodash.get function */
function getProp( object, keys, defaultVal ){
keys = Array.isArray( keys )? keys : keys.split('.');
object = object[keys[0]];
if( object && keys.length>1 ){
return getProp( object, keys.slice(1) );
}
return object === undefined? defaultVal : object;
}

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@mgibbs189
mgibbs189 / functions.php
Created March 6, 2018 13:27
Pre-fill the search box if not filled
<?php
// Add to your (child) theme's functions.php
add_filter( 'facetwp_render_params', function( $params ) {
foreach ( $params['facets'] as $key => $facet ) {
if ( 'keywords' == $facet['facet_name'] ) { // change "keywords" to your actual facet name
if ( empty( $facet['selected_values'] ) ) {
$params['facets'][ $key ]['selected_values'] = 'circ';
}
var cloudinary = require('cloudinary').v2;
cloudinary.config({
cloud_name: "<CLOUD NAME>",
api_key: "<API KEY>",
api_secret: "<API SECRET>"
});
var result = [];
var options = { type: "upload", max_results: 500, prefix: "<Name of the Folder>/" }; //Add you folder name + `/`
@fnky
fnky / ANSI.md
Last active April 27, 2025 09:00
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@nwaughachukwuma
nwaughachukwuma / User.php
Last active March 28, 2020 21:41
A user model with it's relationships
<?
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
public function photos()
{
return $this->hasMany('\App\Photo');
}
public function posts()
{