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
@stalniy
stalniy / scale-canvas.js
Created September 10, 2018 11:14 — forked from callumlocke/scale-canvas.ts
Function to fix a canvas so it will look good on retina/hi-DPI screens.
/**
* This function takes a canvas, context, width and height. It scales both the
* canvas and the context in such a way that everything you draw will be as
* sharp as possible for the device.
*
* It doesn't return anything, it just modifies whatever canvas and context you
* pass in.
*
* Adapted from Paul Lewis's code here:
* http://www.html5rocks.com/en/tutorials/canvas/hidpi/
@stalniy
stalniy / create_debian-sys-maint_for_mysqladmin.sh
Created February 25, 2018 07:10 — forked from waja/create_debian-sys-maint_for_mysqladmin.sh
Create 'debian-sys-maint' MariaDB user for use of mysqladmin. Just in case you can't use 'root' via 'unix_socket' plugin.
#!/bin/sh
MYSQLADMIN_CFG="/etc/mysql/mariadb.conf.d/90-mysqladmin.cnf"
# generate password
PASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
# adjust /etc/mysql/debian.cnf (used as defaults file by system scripts)
sed -i "s/^password =.*$/password = ${PASS}/" /etc/mysql/debian.cnf
sed -i "s/^user =.*$/user = debian-sys-maint/" /etc/mysql/debian.cnf
# create config file for mysqladmin itself (maybe not needed)
umask 066
cat > ${MYSQLADMIN_CFG} <<EOF
@stalniy
stalniy / disable.sh
Created January 20, 2018 05:19
Disable bunch of #$!@ in Sierra (Version 2.1)
#!/bin/bash
# IMPORTANT: You will need to disable SIP aka Rootless in order to fully execute this script, you can reenable it after.
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
# Agents to disable
TODISABLE=('com.apple.security.keychainsyncingoveridsproxy' 'com.apple.personad' 'com.apple.passd' 'com.apple.screensharing.MessagesAgent' 'com.apple.CommCenter-osx' 'com.apple.Maps.mapspushd' 'com.apple.Maps.pushdaemon' 'com.apple.photoanalysisd' 'com.apple.telephonyutilities.callservicesd' 'com.apple.AirPlayUIAgent' 'com.apple.AirPortBaseStationAgent' 'com.apple.CalendarAgent' 'com.apple.DictationIM' 'com.apple.iCloudUserNotifications' 'com.apple.familycircled' 'com.apple.familycontrols.useragent' 'com.apple.familynotificationd' 'com.apple.gamed' 'com.apple.icloud.findmydeviced.findmydevi
@stalniy
stalniy / jasmine-this-vars.md
Last active January 9, 2018 05:59 — forked from traviskaufman/jasmine-this-vars.md
Better Jasmine Tests With `lazy vars`

Better Jasmine Tests With lazy vars

All of my unit tests are written using Jasmine or Mocha, an awesome BDD libraries. Recently I switched how data for tests is set up from declaring and assigning to closures, to defining lazy variables using bdd-lazy-var, and I've seen some awesome benefits from doing such.

The old way

Up until recently, a typical unit test looked something like this:

var BaseClass = require('../../www/BaseClass')
@stalniy
stalniy / submit-google-form.js
Created August 16, 2017 08:12
Submit google form
function c(name) {
return $x(`//div[@role="listitem" and @jscontroller and .//*[@role="heading" and text()[contains(., "${name}")]]]`)[0];
}
function report(attrs) {
const name = c('Name');
name.click();
setTimeout(() => {
@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 / Appfile.rb
Created August 31, 2016 11:32 — forked from ravishtiwari/Appfile.rb
Ionic Build IPA with Fastlane tool
app_identifier "com.yourorganization.mytodoapp" # The bundle identifier of your app
apple_id "<You Apple Id>" # Your Apple email address
# You can uncomment any of the lines below and add your own
# team selection in case you're in multiple teams
# team_name "CAMobileApp"
# team_id "Q2CBPJ58CA"
# you can even provide different app identifiers, Apple IDs and team names per lane:
# https://github.com/KrauseFx/fastlane/blob/master/docs/Appfile.md
# 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
/*
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",