Skip to content

Instantly share code, notes, and snippets.

View jibwa's full-sized avatar

Joshua White jibwa

  • Jibwa LLC Digital Product Services
  • Tucson, AZ
View GitHub Profile
@jibwa
jibwa / updateitem.js
Created December 4, 2019 23:23
updateItem example no mutation
selectService(
context: StateContext<ServiceDetailDialogModel>,
{ payload: {
serviceName,
doSelect
} }: ServiceDetailDialogActions.SelectService) {
const { serviceHosts } = context.getState();
// get the index
const serviceIndex: number = serviceHosts.findIndex(service_ => service_.serviceName === serviceName);
if (serviceIndex < 0) {
@jibwa
jibwa / example.js
Last active December 4, 2019 23:28
Appropriate mutation
// HELPER at top of file, or in util
const cloneSetAllSelected = (serviceHosts, selected: boolean = false) => {
return serviceHosts.map(service => ({
...service,
selected,
hosts: service.hosts.map(host => ({
..host,
selected
}))
}));
@jibwa
jibwa / gist:e4b96eeac32f4dc287b979ada4ff1bd5
Created April 16, 2017 03:20
Bluebird es6 elegant async promise with data response example
import Promise from 'Bluebird';
Promise.join(
Product.create({
name: 'MacbookPro',
qty: 1232213,
price: 10000.
}),
Order.findOne({
orderNumber: 123
})
@jibwa
jibwa / gist:6eb68778a22957fa9dbbb87b9cd2a4e3
Created April 16, 2017 03:17
Plain es6 promise solution to async with followup and collecting args for response
Promise.all([
Product.create({
name: 'MacbookPro',
qty: 1232213,
price: 10000.
}),
Order.findOne({
orderNumber: 123
})
])
@jibwa
jibwa / Intro
Last active August 29, 2015 14:13
The case and rules for formatting HTML in 2015
HTML has grown up and so should the way we format it. Despite early objections, nearly every developer and team which has adopted this formatting realizes it is supremely better at:
1.) Collaboration and Version Control
2.) Reads Easier and Faster
3.) Separation of Concerns
Under the current standards of html we see a lot of this:
<span class="my-class" custom-attribute="an-attribute" id="thing1" inline-js-exec="something===another">Some Content</span>
@jibwa
jibwa / gist:dffe72290d9f8bc5c6eb
Created December 29, 2014 17:16
Reusable resolver across multiple configs.
//////// File MyResolversProvider.js ////////
function MyResolversProvider(){
this.$get = function(){
return {
myResolver: ($stateParams, $resource){
console.log($stateParams);
return {message: "Success"};
}
}
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@jibwa
jibwa / sample.coffee
Last active August 29, 2015 14:05
Coffee and Angular with Inheritance.
app = angular.module('lcs.entityViews')
# File entity_controller.coffee
# The entity controller expects a meta property and auto-updes
# Use the factory to create the class which will be extended
# This makes it possible to be injected and extend in any file on the filesystem
app.factory 'EntityController', (MetaProvider) ->
@jibwa
jibwa / prerender.coffee
Created April 15, 2014 01:33
simple directive to remove the prerenderReady after five seconds
# This is required to prerender views for google indexing
app.directive 'prerenderReady', ($timeout, $window) ->
link: ->
$timeout( ->
$window.prerenderReady = true
, 5000)