Skip to content

Instantly share code, notes, and snippets.

View winkerVSbecks's full-sized avatar
🥵

Varun Vachhar winkerVSbecks

🥵
View GitHub Profile
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
title.charAt(index - 1).search(/[^\s-]/) < 0) {
return match.toLowerCase();
}
@winkerVSbecks
winkerVSbecks / ui.css
Created March 13, 2015 00:51
Browser chrome
.fake-browser-ui {
padding: 20px 0 0;
border-radius: 3px;
border-bottom: 2px solid #ccc;
background: #ddd;
display: inline-block;
position: relative;
line-height: 0;
}
@winkerVSbecks
winkerVSbecks / redis.md
Created March 19, 2015 21:41
Redis stuff

To have launchd start redis at login:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

Then to load redis now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Or, if you don't want/need launchctl, you can just run:
redis-server /usr/local/etc/redis.conf

@winkerVSbecks
winkerVSbecks / SassMeister-input.scss
Created May 20, 2015 02:12
Generated by SassMeister.com.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
@mixin btn-gen($bg, $color, $border, $hover-bg, $hover-border, $hover-color) {
background-color: $bg;
color: $color;
border: 1px solid $border;
@winkerVSbecks
winkerVSbecks / es6-vs-es5.js
Created January 11, 2016 17:44
es6-vs-es5
// ES5
SomePromise()
.then(function(result) {
return doSomething(result)
})
.catch(function (err) {
console.log(err.message)
});
// ES6
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
var componentData = [{
"id": "0",
"name": "TodoList",
"children": [{
"id": "0.0",
"name": "INPUT"
}, {
"id": "0.1",
"name": "NgIf"
}, {
@winkerVSbecks
winkerVSbecks / poll.js
Created October 2, 2016 17:45
angular 2 observable polling
Rx.Observable
.interval(500)
.flatMap(() => [1, 2, 3] /* in angular you will call getData() to make an HTTP request */)
.map(x => x + 1)
.subscribe(x => console.log(x))
function getData() {
return this.http
.get('https://api.spotify.com/v1/search?q=' + term + '&type=artist')
.map((response) => response.json())
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->