Skip to content

Instantly share code, notes, and snippets.

View msurguy's full-sized avatar

Maksim Surguy msurguy

View GitHub Profile
@msurguy
msurguy / getrandom.php
Last active August 29, 2015 13:55
Get 3 random items from a category
$site = Site::approved()->featured()->where('slug',$slug)->first();
$related = array();
if(count($site->categories) > 0){
$categoryIDs = array();
foreach ($site->categories as $category) {
$categoryIDs[] = $category->id ;
}
shuffle($categoryIDs);
$relatedCategory = Category::with(array('sites' => function($query)
@msurguy
msurguy / speaking.md
Last active August 29, 2015 13:55
My speaking experience
@msurguy
msurguy / index.blade.php
Created February 9, 2014 00:38
Example of extracting JS files for AJAX in Laravel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AJAX</title>
</head>
<body>
@msurguy
msurguy / upload.php
Last active August 29, 2015 13:56
using jquery fileAPI plugin (https://github.com/RubaXa/jquery.fileapi/) with Intervention Image class (intervention.olivervogel.net) to upload and resize images
ini_set("memory_limit","200M");
if( !empty($_SERVER['HTTP_ORIGIN']) ){
// Enable CORS
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type');
}
if( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ){
@msurguy
msurguy / common.txt
Last active August 29, 2015 14:00
Wallpaper resolutions
Resolution Ratio
2560 x 1440 1.777
1920 x 1440 1.333
1920 x 1200 1.6
1920 x 1080 1.777
1680 x 1200 1.4
1680 x 1050 1.6
1600 x 1200 1.333
1440 x 900 1.6
1400 x 1050 1.333
@msurguy
msurguy / CleanDirs.php
Created May 8, 2014 07:05
Clean temporary folders
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class CleanDirs extends Command {
protected $name = 'cleandirs';
@msurguy
msurguy / Boxfile
Last active August 29, 2015 14:01
Sample Boxfile (for a laravel application) and example of using DB credentials in the app
web1:
document_root: public
php_version: 5.4.14
php_upload_max_filesize: "10M"
php_post_max_size: "10M"
php_extensions:
- mbstring
- mcrypt
- curl
- gd
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
// Use this if you believe the iframe may have dynamic content and could change size after it has completely loaded //
// Your Domain Name //
var parent_domain = "http://www.example.com/";
setInterval(function() {
var iframe_height = parseInt($('html').height());
// Add Padding to insure nothing is creating a scroll bar //
iframe_height += 30;
@msurguy
msurguy / demo.html
Created April 30, 2015 19:20
canvas css image
<!DOCTYPE html>
<!--
Copyright 2012 Eric Bidelman
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0