Skip to content

Instantly share code, notes, and snippets.

View osben's full-sized avatar
🐱
dev

Yevhen Yerko osben

🐱
dev
View GitHub Profile
@hdragomir
hdragomir / sm-annotated.html
Last active February 2, 2025 02:22
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@hdragomir
hdragomir / index.html
Created July 7, 2014 09:48
IIFE version of SM Font Loading
<script type="text/javascript">
(function (css_href) {
"use strict";
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
} else if (el.attachEvent) {
el.attachEvent("on" + ev, callback);
@milo
milo / github-webhook-handler.php
Last active October 29, 2024 15:45
GitHub Webhook Handler
<?php
/**
* GitHub webhook handler template.
*
* @see https://docs.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check
@ryantbrown
ryantbrown / gulp-resize-and-minify-images.js
Last active October 9, 2024 21:50
Gulp - Resize and Optimize / Minify Images
/**
* Make sure Graphicsmagick is installed on your system
* osx: brew install graphicsmagick
* ubuntu: apt-get install graphicsmagick
*
* Install these gulp plugins
* glup, gulp-image-resize, gulp-imagemin and imagemin-pngquant
*
* Group images according to their output dimensions.
* (ex: place all portfolio images into "images/portfolio"
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
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
@osben
osben / StartSSL SSL Labs A+
Last active October 13, 2016 08:57
StartSSL SSL Labs A+ nginx.conf
ssl_session_cache shared:ssl_session_cache:10m;
server {
server_name domen.com www.domen.com;
listen xxx.xxx.xxx.xxx:80;
return 301 https://domen.com$request_uri;
}
server {
server_name domen.com www.domen.com;
listen 443 ssl spdy;
@osben
osben / css3radios.css
Last active July 26, 2016 14:39 — forked from andremescaline/css3radios.css
css3-radios
.css3-radios label {
display: inline-block;
vertical-align: middle;
}
.css3-radios input[type="radio"] + span {
display: inline-block;
vertical-align: middle;
}
.css3-radios input[type="radio"] + span::before {
display: inline-block;
@m1m1s1ku
m1m1s1ku / opti.php
Created November 13, 2016 00:34
Optimize jpg/png using PHP/Exec
<?php
exec("find /var/www/FOLDER/img/ -type f -name '*.jpg' -exec jpegoptim --strip-all {} \;");
exec("find /var/www/FOLDER/img/ -type f -name '*.JPG' -exec jpegoptim --strip-all {} \;"); // Sometimes, .jpg are.. .JPG
exec("find /var/www/FOLDER/img/ -type f -name '*.png' -exec optipng -o2 {} \;"); // Level 2, change to -o2 => -o7
mail('[email protected]', 'Server', 'Jpg/Png opti done');
?>
@sbose78
sbose78 / update-version-package.sh
Last active April 11, 2024 19:36
Pre-commit hook to update package.json
#!/bin/bash
set -e
update_version(){
if [[ "$DONT_BUMP_VERSION" -ne "1" ]]
then
echo " Bumping version.. "
else
echo "Version will not be bumped since variable DONT_BUMP_VERSION is set."
exit 0
@TomCosta
TomCosta / Ionic-3-CPF_CNPJ-input-mask
Created October 22, 2017 00:59
Ionic 3 CPF/CNPJ input mask. Independent of which is the inputted data either a CPF or a CNPJ. It add mask.
<form #loginForm="ngForm">
<ion-item>
<ion-label floating>CPF/CNPJ</ion-label>
<ion-input [(ngModel)]="cpf_cnpj" (blur)="cpf_cnpj = format(cpf_cnpj)" name="cpf_cnpj"></ion-input>
</ion-item>
<button ion-button full type="submit" color="sicor" (tap)="login(signForm.value)">Login</button>
</form>