Skip to content

Instantly share code, notes, and snippets.

View stalniy's full-sized avatar
🏠
Working from home

Sergii Stotskyi stalniy

🏠
Working from home
View GitHub Profile
/*
After jquery ui datepicker selection, blur and change
events fire before focus is returned to the input field,
handling a quirk from IE browsers
*/
$("input.dateInput").datepicker({
changeMonth: true,
changeYear: true,
showAnim: "fadeIn",
@stalniy
stalniy / config.json
Last active August 29, 2015 14:06
bootstrap.json
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "#83919e",
"@gray": "#c1cad3",
"@gray-light": "lighten(#000, 60%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#309df0",
"@brand-success": "#00b800",
"@brand-info": "#00c6d8",
# Here's the script I'll use to demonstrate - it just loops forever:
$ cat test.rb
#!/usr/bin/env ruby
loop do
sleep 1
end
# Now, I'll start the script in the background, and redirect stdout and stderr
@stalniy
stalniy / html-loader-without-white-space.js
Created July 25, 2016 11:27
Configuration for webpack html loader which removes all white spaces between tags
{
root: resolve('src'),
minimize: true,
collapseWhitespace: true,
conservativeCollapse: false,
collapseInlineTagWhitespace: true,
removeAttributeQuotes: false,
caseSensitive: true,
customAttrSurround: [
[/#/, /(?:)/],
@stalniy
stalniy / GIF-Screencast-OSX.md
Created September 14, 2016 08:08 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@stalniy
stalniy / import-gitlab.sh
Created November 22, 2016 13:45
Creates and pushes projects from one gitlab to another
#!/bin/bash
# Put proper URLs here
SOURCE_GITLAB_URL=http://source.example.net/api/v3/
DESTINATION_GITLAB_URL=http://dest.example.net/api/v3/
DESTINATION_GIT_URL=git@dest.example.net
SOURCE_PRIVATE_KEY=
DESTINATION_PRIVATE_KEY=
TMP_DIR=`mktemp -d`
@stalniy
stalniy / abilities.js
Last active July 24, 2017 20:02
CASL in expressjs app
const { AbilityBuilder, Ability } = require('casl')
function defineAbilitiesFor(user) {
const { rules, can } = AbilityBuilder.extract()
can('read', ['Post', 'Comment'])
can('create', 'User')
if (user) {
can('manage', ['Post', 'Comment'], { author: user._id })
@stalniy
stalniy / abilities.js
Created July 24, 2017 20:03
CASL expressjs changed
function defineAbilitiesFor(user) {
const { rules, can } = AbilityBuilder.extract()
if (user) {
can('manage', ['Post', 'Comment'], { author: user._id })
can(['read', 'update'], 'User', { _id: user.id })
} else {
can('read', ['Post', 'Comment'])
can('create', 'User')
}
@stalniy
stalniy / abilities.js
Created July 26, 2017 12:03
CASL blog app abilities ES6
import { AbilityBuilder } from 'casl'
const user = whateverLogicToGetUser()
const ability = AbilityBuidler.define(can => {
can('read', ['Post', 'Comment'])
if (user.isLoggedIn) {
can('create', 'Post')
can('manage', ['Post', 'Comment'], { authorId: user.id })
}
@stalniy
stalniy / mongo-query.js
Created July 26, 2017 13:09
CASL and mongoose
const { mongoosePlugin, AbilityBuilder } = require('casl')
const mongoose = require('mongoose')
mongoose.plugin(mongoosePlugin)
const Post = mongoose.model('Post', mongoose.Schema({
title: String,
author: String,
content: String,
createdAt: Date