Skip to content

Instantly share code, notes, and snippets.

Dmitri Moore demisx

Block or report user

Report or block demisx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View enable-slack-dark-mode.sh
# For macOS users (copy & paste all or one commands at a time)
# Last tested Slack version: 4.0.2
$ git clone https://github.com/LanikSJ/slack-dark-mode && \
cd slack-dark-mode && \
chmod +x slack-dark-mode.sh && \
./slack-dark-mode.sh && \
osascript -e 'tell application "Slack" to quit' && \
killall Slack && \
sleep 20 && \
open -a "/Applications/Slack.app"
@demisx
demisx / bookshelf.md
Last active Jan 25, 2016
BookshelfJS
View bookshelf.md
  • There is no exposed reference from the model to bookshelf (e.g. can't do something like Ad.Bookshelf.knex). Need to require the bookshelf instance itself.

Getting count of models matching certain criteria

// select count(*) from "ads" where "classified_id" = 2'
Ad.where({ classified_id: 2 })
  .query() // <- returns QueryBuild instance
  .count()
  .then(function (count) {
    console.log('\n***', count);
@demisx
demisx / angularjs1-unit-test.md
Last active Jan 28, 2018
AngularJS 1.x Unit Testing with Mocha/Chai/Chai-as-promised
View angularjs1-unit-test.md

UI States

describe('state', function() {
  var stateName ='app.classified';
  var $state;
  var h;

  beforeEach(function() {
    module('unitTestTemplates');
    module('helpers.unit.state');
@demisx
demisx / gulpfile.js
Last active Sep 18, 2019
Gulp 4 gulpfile.js
View gulpfile.js
// Gulp 4
var gulp = require('gulp');
var using = require('gulp-using');
var grep = require('gulp-grep');
var changed = require('gulp-changed');
var del = require('del');
var coffee = require('gulp-coffee');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var sourcemaps = require('gulp-sourcemaps');
View _angularjs-1-component-organization.md

Angular application directory structure

Leverages Angular UI Router instead of core ngRoute module. UI Router allows us to organize our application interface into a state machine. Unlike the $route service in the Angular ngRoute module, which is organized around URL routes, UI-Router is organized around states, which may optionally have routes, as well as other behavior, attached.

LIFT* Organization principle:

  • L - Locating code easy
  • I - Identify code at a glance
@demisx
demisx / syntax.css
Last active Oct 4, 2019
Syntax highlighter CSS file
View syntax.css
.highlight { background: #ffffff; }
.highlight .c { color: #999988; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { font-weight: bold } /* Keyword */
.highlight .o { font-weight: bold } /* Operator */
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
@demisx
demisx / javascript-falsy-vs-truthy.md
Created Apr 26, 2014
JavaScript Falsy vs. Truthy
View javascript-falsy-vs-truthy.md

The following values are always falsy:

  • false
  • 0 (zero)
  • "" (empty string)
  • null
  • undefined
  • NaN (a special Number value meaning Not-a-Number!)

All other values are truthy, including "0" (zero in quotes), "false" (false in quotes), empty functions, empty arrays, and empty objects.

@demisx
demisx / webrick-ssl.rb
Created Apr 17, 2014
Configure Webrick Server as SSL
View webrick-ssl.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
module Rails
class Server < ::Rack::Server
def default_options
@demisx
demisx / gist:10417077
Created Apr 10, 2014
Generate Self-signed SSL certificate
View gist:10417077
$ openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout server.key -out server.crt
You can’t perform that action at this time.