Skip to content

Instantly share code, notes, and snippets.

Hrvoje Šimić shime

Block or report user

Report or block shime

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
@shime
shime / kata.md
Created Nov 19, 2014
text from kata at http://www.codewars.com/kata/a-chain-adding-function/. solution is in 3 lines of code.
View kata.md

We want to create a function that will add numbers together when called in succession.

add(1)(2) == 3 // true

We also want to be able to continue to add numbers to our chain.

add(1)(2)(3) == 6 // true
@shime
shime / rc.xml
Created Nov 6, 2014
openbox shortcuts for window management
View rc.xml
<keyboard>
<!-- resize windows with Alt + Direction -->
<keybind key="A-Right">
<action name="GrowToEdgeEast"/>
</keybind>
<keybind key="A-Left">
<action name="GrowToEdgeWest"/>
</keybind>
<keybind key="A-Down">
<action name="GrowToEdgeSouth"/>
@shime
shime / ngnix.conf
Created Oct 31, 2014
redirect non-www to www with or without ssl in ngnix
View ngnix.conf
# http://domain.com -> https://www.domain.com
# http://www.domain.com -> https://www.domain.com
server {
listen 80;
server_name domain.com www.domain.com;
return 301 https://www.domain.com$request_uri;
}
# https://domain.com -> https://www.domain.com
server {
@shime
shime / list_files.js
Created Oct 9, 2014
list files in a directory with node.js
View list_files.js
var fs = require('fs'),
path = require('path')
var listFiles = function(dir, next){
fs.readdir(dir, function(err, nodes){
if (err) next(err)
next(null, nodes.filter(function(node){
return fs.lstatSync(path.resolve(dir) + "/" + node).isFile()
}))
})
@shime
shime / readme.md
Created Sep 30, 2014
run the minitest test suite without rake
View readme.md

To run bunch of Minitest tests in one go, without using Rake, use this command

$ ruby -e 'ARGV.each { |path| require "./#{path}" }' test/*.rb
@shime
shime / _readme.md
Last active Nov 11, 2019
github oauth in node using express
View _readme.md

What?

Most basic example of authenticating with Github in node.

How?

Clone this gist, change keys inside config.js and then hit npm install && node app.js.

Done?

@shime
shime / _README.md
Last active Apr 22, 2019
comparing dates and times in RSpec
View _README.md

What is this?

How do you compare date/times in RSpec?

If you do this

expect(Time.now.to_i).to eq Time.new(2014, 4, 2).to_i
@shime
shime / test.coffee
Created Jan 16, 2014
testing Ember.RSVP with QUnit
View test.coffee
test "the Ember.RSVP.Promise works", ->
promise = new Ember.RSVP.Promise((resolve, reject) ->
Ember.run(null, resolve, "value")
)
Ember.run =>
promise.then (actual) ->
equal(actual, 'value', 'promise resolved with "hello"')
@shime
shime / _readme.md
Created Nov 28, 2013
easier renaming and moving of files in vim
View _readme.md

Simple function that makes moving and renaming files in Vim much easier.

Usage

Place it in your ~/.vimrc.

I'm calling it with <leader>N here, map it to anything you like.

@shime
shime / artists.json
Created Nov 2, 2013
some good electroswing artists
View artists.json
{
"artists": [
"parov stelar",
"proleter",
"goldfish",
"tape five",
"movits",
"odjbox"
]
}
You can’t perform that action at this time.