Skip to content

Instantly share code, notes, and snippets.

@SergeyMaas
SergeyMaas / keybase.md
Created September 12, 2019 02:32
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@SergeyMaas
SergeyMaas / youtube_id_regex.php
Created March 1, 2019 14:11 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@SergeyMaas
SergeyMaas / graphics_magick_center_image_on_canvas.js
Created March 7, 2017 19:38 — forked from edwardhotchkiss/graphics_magick_center_image_on_canvas.js
Use GM Module (Graphics Magick) for Node.js to center an image on a white background canvas
var gm = require('gm');
var canvasWidth = 248;
var canvasHeight = 389;
gm(__dirname + '/original.jpg').size(function(error, size) {
if (error) {
console.error(error);
@SergeyMaas
SergeyMaas / graphics_magick_center_image_on_canvas.js
Created March 7, 2017 19:38 — forked from edwardhotchkiss/graphics_magick_center_image_on_canvas.js
Use GM Module (Graphics Magick) for Node.js to center an image on a white background canvas
var gm = require('gm');
var canvasWidth = 248;
var canvasHeight = 389;
gm(__dirname + '/original.jpg').size(function(error, size) {
if (error) {
console.error(error);
@SergeyMaas
SergeyMaas / uri.js
Created October 20, 2016 11:02 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@SergeyMaas
SergeyMaas / boot.js
Created December 1, 2015 09:51 — forked from jdx/boot.js
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
/*
Валидация номера моб.телефона
*/
function validateMobilePhoneNumBer(phone){
if(phone !== undefined)
{
var regExp = /^((\+?7|8)?) \((900|901|902|903|905|906|908|909|910|911|912|913|914|915|916|917|918|919|920|921|922|923|924|925|926|927|928|929|929|930|931|932|933|934|935|936|937|938|939|941||950|951|952|953|954|955|956|958|960|961|962|963|964|965|966|967|968|969|970|971|976|980|981|982|983|984|985|986|987|988|989|991|992|993|994|995|996|997|999)\) ?(\d{3}\-?\d{4})$/;
var result = phone.match(regExp);
return result && result[0] == phone;
}
@SergeyMaas
SergeyMaas / gulpfile.js
Last active August 29, 2015 14:26 — forked from campezzi/gulpfile.js
Gulp + Browserify + Reactify + Watch + LiveReload
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var reactify = require('reactify');
var notify = require("gulp-notify");
var livereload = require('gulp-livereload');
var scriptsDir = './src/js';
var buildDir = './public/js';
@SergeyMaas
SergeyMaas / Gulpfile.js
Last active August 29, 2015 14:26 — forked from nbqx/Gulpfile.js
for browserify (reactify)
var browserify = require('browserify'),
gulp = require('gulp'),
source = require('vinyl-source-stream'),
brfs = require('brfs'), // -> if use
babelify = require('babelify'), // -> for es6, react
uglify = require('gulp-uglify');
var liveServer = require('live-server');
gulp.task('browserify', function() {
@SergeyMaas
SergeyMaas / git.css
Last active August 29, 2015 14:20 — forked from neilgee/git.css
/* Set up Git Configuration */
git config --global user.email "you@yourdomain.com"
git config --global user.name "Your Name"
git config --global core.editor "vi"
git config --global color.ui true