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 / 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 / RouteClass.php
Created October 1, 2015 11:25 — forked from dwightwatson/RouteClass.php
Get the controller name and action in Laravel 4 which can be used as a class in your HTML. This solution makes use of the parseCallback() and currentRouteAction() functions, which are handy if you want to devise your own version.
<?php
public function routeClass()
{
$routeArray = Str::parseCallback(Route::currentRouteAction(), null);
if (last($routeArray) != null) {
// Remove 'controller' from the controller name.
$controller = str_replace('Controller', '', class_basename(head($routeArray)));
if (!window.location.origin) { // Some browsers (mainly IE) does not have this property, so we need to build it manually...
window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? (':' + window.location.port) : '');
}