Skip to content

Instantly share code, notes, and snippets.

View SleeplessByte's full-sized avatar
💎
💎 💎 💎

Derk-Jan Karrenbeld SleeplessByte

💎
💎 💎 💎
View GitHub Profile
@SleeplessByte
SleeplessByte / my_base_entity.rb
Created July 27, 2015 13:21
Access Grape Routes from entity
class MyBaseEntity < Grape::Entity
include GrapeRouteHelpers::NamedRouteMatcher
end
@SleeplessByte
SleeplessByte / api-namespace-api.rb
Created July 27, 2015 13:23
Use same format, prefix, formatter and error handler for multiple grape api's
module Namespace
module API
extend ActiveSupport::Concern
included do
format :xml
prefix :api
formatter :xml, xml_formatter
rescue_from :all do |e|
@SleeplessByte
SleeplessByte / empty_my_model.rb
Created July 27, 2015 13:26
Empty default active record
class EmptyMyModel < Delegator
def initialize
super @_delegated_object = MyModel.new(
#mydefaultparamters,
id: 0
)
end
def __getobj__
<!-- Add to homescreen for Chrome on Android -->
<meta name="mobile-web-app-capable" content="yes">
<link rel="icon" sizes="192x192" href="<!-- a touch icon -->">
<meta name="theme-color" content="<!-- status bar color -->">
<!-- Add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="<!-- status bar color -->">
<meta name="apple-mobile-web-app-title" content="<!-- application name short -->">
source 'https://rubygems.org'
gem 'rambling-trie'
### end gemfile
require 'rubygems'
require 'bundler/setup'
require 'rambling-trie'
require 'optparse'
/*!
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Script: jQuery throttle / debounce: Sometimes, less is more!
/**
* Setups an autocomplete subscription
*
* @template T
* @param {Observable<string>} input$ stream of autocomplete-values
* @param {HTMLInputElement} input the input source
* @param {Element} startBtn the element to start a query manually
* @param {Element} cancelBtn the element to end any query
* @param {(value: T) => void} notifier that there is a definitive value
* @param {(q: string) => Observable<T>} doQuery returns observable doing the query
@SleeplessByte
SleeplessByte / preact-bootstrap-with-sass.md
Last active September 5, 2018 00:38
Preact Bootstrap modifications to use sass / scss

Preact-Bootstrap with scss

To switch from less to sass / scss take the following steps:

1. Install sass loader

npm install sass-loader node-sass --save-dev
npm uninstall less-loader --save-dev

2. Rename .less to .scss

@SleeplessByte
SleeplessByte / tslint.json
Last active April 24, 2017 21:38
Default tslint
{
"rulesDirectory": [
],
"rules": {
"adjacent-overload-signatures": true,
"member-access": false,
"member-ordering": [
true,
{ "order": [
@SleeplessByte
SleeplessByte / tsconfig.json
Created April 24, 2017 21:39
Default tsconfig.json
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": false,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"baseUrl": "./src",