Skip to content

Instantly share code, notes, and snippets.

View demisx's full-sized avatar

Dmitri demisx

View GitHub Profile
# 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 / macosx-configure-postfix-as-relay.md
Created October 17, 2018 02:41 — forked from loziju/macosx-configure-postfix-as-relay.md
Configure postfix as relay for OS X
@demisx
demisx / bookshelf.md
Last active January 25, 2016 18:18
BookshelfJS
  • 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 January 28, 2018 03:56
AngularJS 1.x Unit Testing with Mocha/Chai/Chai-as-promised

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 July 14, 2022 16:06
Gulp 4 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');
@demisx
demisx / _angularjs-1-component-organization.md
Last active July 14, 2023 14:07
AngularAtom--Component-based organization for AngularJS 1.x apps. Read more on AngularAtom organization at http://demisx.github.io/angularjs/atom/component-feature-based-organization/2014/12/02/angular-1-component-organization-1.html

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 February 20, 2020 04:32
Syntax highlighter CSS file
.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 April 26, 2014 03:53
JavaScript Falsy vs. Truthy

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 April 17, 2014 16:57
Configure Webrick Server as SSL
#!/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 April 10, 2014 19:55
Generate Self-signed SSL certificate
$ openssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout server.key -out server.crt