Skip to content

Instantly share code, notes, and snippets.

@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
@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 "[email protected]"
git config --global user.name "Your Name"
git config --global core.editor "vi"
git config --global color.ui true