Skip to content

Instantly share code, notes, and snippets.

Nik Sumeiko niksumeiko

Block or report user

Report or block niksumeiko

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
@niksumeiko
niksumeiko / git-rebase-master-ohmyzsh-alias.zsh
Last active Dec 6, 2019
Git rebase current branch onto latest master without switching · ohmyzsh custom alias
View git-rebase-master-ohmyzsh-alias.zsh
# ~/.oh-my-zsh/custom/git-rebase-master-ohmyzsh-alias.zsh
grbmo() {
branch=$(current_branch)
echo "Current branch: $branch"
echo "Switching to master to pull latest..."
gcm && ggl # git checkout master && git pull
echo "Master is up to date"
gco $branch # git checkout $branch
echo "Back to $branch, rebasing..."
@niksumeiko
niksumeiko / sendToNative.ts
Created May 16, 2017
Sending data from webView to native Android/iOS layer in hybrid mobile app
View sendToNative.ts
function sendToNative(data: string) {
if (/android/i.test(window.navigator.userAgent)) {
if (window.quicketNative) {
return window.quicketNative.send(data);
}
}
let frame = document.createElement('iframe');
frame.width = '100';
@niksumeiko
niksumeiko / mongoose-findOrCreate.js
Last active Apr 15, 2019
Mongoose schema static `findOrCreate` method in ES6/7 async/await syntax
View mongoose-findOrCreate.js
import mongoose from 'mongoose';
let schema = new mongoose.Schema({
email: { type: String, required: true, unique: true },
password: { type: String, required: true }
});
schema.statics.findOrCreate = async (conditions, opt_attr) => {
let document = await User.findOne(conditions);
@niksumeiko
niksumeiko / disable-html-form-input-autocomplete-autofill.md
Last active Dec 11, 2019
Disable HTML form input autocomplete and autofill
View disable-html-form-input-autocomplete-autofill.md

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@niksumeiko
niksumeiko / object-to-style-attribute.js
Created Jun 30, 2015
Converts style object into the corresponding CSS `style` attribute value
View object-to-style-attribute.js
/**
* Takes a style object and returns the corresponding
* attribute value. Converts camel case property names
* to proper CSS selector names.
* @param {Object} obj Map of CSS properties to values.
* @return {string} The style attribute value.
*/
function toStyleAttribute = function(obj) {
return Object.keys(obj).map(function(key) {
@niksumeiko
niksumeiko / sum-function-arguments.js
Created Jun 30, 2015
Sums up function arguments
View sum-function-arguments.js
/**
* Sums up all given arguments.
* @param {...*} var_args Numbers or numbers alike to sum up.
* Numbers will be added as is, numbers in strings (e.g. '123.45')
* will be converted to numbers and added. NaNs are skipped.
* @return {number} The sum of number arguments.
*/
function sum(var_args) {
var args = [].slice.call(arguments);
@niksumeiko
niksumeiko / promises-chaining.js
Last active Aug 29, 2015
Promises chaining that solves "callbacks hell"
View promises-chaining.js
'use strict';
var Promise = require('promise');
function build() {
return new Promise(function(fulfill, reject) {
fulfill('zero');
});
@niksumeiko
niksumeiko / catching-promise-errors.js
Last active Jul 15, 2017
Catching errors thrown inside Nodejs promise
View catching-promise-errors.js
'use strict';
var Promise = require('promise');
/** @desc A function that returns a promise with an error-prone code. */
function build() {
return new Promise(function(fulfill, reject) {
@niksumeiko
niksumeiko / exercises.creditcard.js
Created Apr 22, 2014
JavaScript exercise that requires to create credit card input fields validation functions.
View exercises.creditcard.js
/**
* @fileoverview Utils Interface credit card validation methods.
* @author (Wind Tammer)
*/
utils = {};
/** @type {Object<Function>} */
utils.creditcard = {};
@niksumeiko
niksumeiko / gslint.conf
Created Apr 7, 2014
Sample Closure Linter configuration file used within WebStorm IDE
View gslint.conf
--strict
--jsdoc
--summary
--beep
--check_html
--nomultiprocess
--debug_indentation
--time
You can’t perform that action at this time.