This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
import subprocess | |
import shlex | |
class RubocopAutofixCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
full_text = self.view.substr(sublime.Region(0, self.view.size())) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
import os | |
class ComponentSwitcherCommand(sublime_plugin.TextCommand): | |
def open_ext(self, filename, ext): | |
file_to_open = f"{filename}{ext}" | |
if os.path.exists(file_to_open): | |
self.view.window().open_file(file_to_open) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Expects a Swedish personnummer formatted as YYYYMMDDXXXX | |
var isLuhn = function(pnr) { | |
var multiplier = 1; | |
var nums = pnr.substr(2).split('').map(function(numStr) { | |
multiplier = 1 + (multiplier % 2); | |
var num = parseInt(numStr) * multiplier; | |
return (num < 10) ? num : num - 9; | |
}); | |
return nums.reduce(function(prev, curr) { return curr + prev; }) % 10 === 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am johanhalse on github. | |
* I am johanhalse (https://keybase.io/johanhalse) on keybase. | |
* I have a public key whose fingerprint is 2B2C EC34 E155 51FF A54F F3FB 6BB5 CC80 F804 D530 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Would be ridiculous to pull in the entire moment.js library for this | |
window.moment = function(dateString) { | |
var date = new Date(dateString); | |
var format = function() { | |
return date.getFullYear() + '-' + | |
('0' + (date.getMonth() + 1)).slice(-2) + '-' + | |
('0' + date.getDate()).slice(-2); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wrapper for Harp web server, to include JS concat/compile step. Put your stuff | |
// in /harp subdirectory, npm install your dependencies, run, enjoy. | |
// Live updating of the concatenated JS file left as an exercise for the reader :) | |
var fs = require('fs'); | |
var path = require('path'); | |
var harp = require('harp'); | |
var UglifyJS = require('uglify-js'); | |
var files = []; | |
files.push(__dirname + '/harp/js/file0.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.0.0 :001 > Article.search 'om' | |
=> #<Searchkick::Results:0x00000006cf3a68 @response={"took"=>68, "timed_out"=>false, | |
"_shards"=>{"total"=>5, "successful"=>5, "failed"=>0}, "hits"=>{"total"=>4, | |
"max_score"=>0.035879318, "hits"=>[{"_index"=>"articles_development_20130827084418630", | |
"_type"=>"article", "_id"=>"1", "_score"=>0.035879318}, | |
{"_index"=>"articles_development_20130827084418630", "_type"=>"article", "_id"=>"2", | |
"_score"=>0.032162987}, {"_index"=>"articles_development_20130827084418630", | |
"_type"=>"article", "_id"=>"3", "_score"=>0.026802491}, | |
{"_index"=>"articles_development_20130827084418630", "_type"=>"article", "_id"=>"4", | |
"_score"=>0.020341659}]}}, @options={:load=>true, :payload=>{:query=>{:dis_max=>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tire::Search::SearchRequestFailed (400 : { | |
"error":"SearchPhaseExecutionException[Failed to execute phase [query], | |
all shards failed; shardFailures { | |
[8LEbz2d7RS6EGrhSp8sNuA][articles_production][4]: | |
SearchParseException[[articles_production][4]: | |
from[-1],size[-1]: Parse Failure [Failed to parse source [{ | |
"query":{ | |
"dis_max":{ | |
"queries":[{ | |
"multi_match":{ |