Skip to content

Instantly share code, notes, and snippets.

@oiljin
oiljin / cuter.py
Created January 24, 2018 11:19 — forked from sigilioso/cuter.py
Python PIL Example: get a thumbnail by resizing and cropping an image.
# -*- coding: utf-8 -*-
import Image
def resize_and_crop(img_path, modified_path, size, crop_type='top'):
"""
Resize and crop an image to fit the specified size.
args:
img_path: path for the image to resize.
@oiljin
oiljin / index.html
Created July 19, 2017 03:22
The button with the circular fill
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<style>
.wrp{
text-align: center;
margin: 50px auto 0;
}
#!/bin/sh
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2>/dev/null);
if [ -n $BRANCH_NAME ] && [ $BRANCH_NAME != 'master' ];
then
echo "$(tr [:lower:] [:upper:] <<< [$BRANCH_NAME]) $(< $1)" > $1;
fi
$ sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
$ xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
@oiljin
oiljin / colorize.php
Created May 11, 2016 07:02
Generating Command Line Colors with PHP
<?php
function colorize($text, $status) {
$out = "";
switch($status) {
case "SUCCESS":
$out = "[42m"; //Green background
break;
case "FAILURE":
$out = "[41m"; //Red background

Boötes

[ Mousemove / TouchSwipe || Click/Tap to Add ]
Interactive 3D system inspired by the Boötes constellation:

A Pen by Tiffany Rayside on CodePen.

License.

@oiljin
oiljin / config_mail.php
Created February 17, 2016 05:22
Laravel update email config on the fly
<?php
config([
'mail.host' => 'smtp.yandex.ru',
'mail.port' => 465,
'mail.encryption' =>'ssl',
'mail.username' => 'username',
'mail.password' => 'password'
]);
$app = App::getInstance();
@oiljin
oiljin / bezierCurve.js
Created December 22, 2015 09:28 — forked from BonsaiDen/bezierCurve.js
Bezier Curve in JS, includes arc-length parameterization stuff
function Bezier(a, b, c, d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.len = 100;
this.arcLengths = new Array(this.len + 1);
this.arcLengths[0] = 0;
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@oiljin
oiljin / checkUrl.js
Last active December 10, 2020 14:41
function isUrl(url) {
var re = /^(http\:\/\/|https\:\/\/)?([a-z0-9][a-z0-9\-]*\.)+[a-z0-9][a-z0-9\-]*[a-z0-9]$/i;
return re.test(url);
}
console.log(isUrl('12domain.ru')); // true
console.log(isUrl('www.domain.com')); // true
console.log(isUrl('http://domain.com')); // true
console.log(isUrl('https://domain.com')); // true