Skip to content

Instantly share code, notes, and snippets.

View msurguy's full-sized avatar

Maksim Surguy msurguy

View GitHub Profile
@msurguy
msurguy / terminal.sh
Created April 19, 2013 18:29
Fix for duplicate/old entries in Mac OS X "open with" menu. Copy and paste this snippet into the terminal and run it to fix those incorrect entries. Relaunch Finder (control+option+click on Finder icon in the Dock)
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\
LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local\
-domain system -domain user
@msurguy
msurguy / upload.php
Created April 18, 2013 17:54
Automatic image rotation from mobile Recently I had a use case when I needed to automatically rotate uploaded pictures according to the sensor data embedded in the image (think iPhone, iPad, Android phones, DSLR cameras, etc) I ended up using PHP Imageworkshop (http://phpimageworkshop.com/documentation.html) for all my image processing needs so …
//retrieve the image
$image = Input::file('image');
// initialize imageworkshop layer
$layer = PHPImageWorkshop\ImageWorkshop::initFromPath($image['tmp_name']);
if (File::is('jpg', $image['tmp_name']))
{
$exif = exif_read_data($image['tmp_name']);
.modal-backdrop {
background: #000;
background: rgba(0,0,0,0.9);
background: -webkit-radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
background: -moz-radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
background: -ms-radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
background: radial-gradient(50% 50%, ellipse closest-corner, rgba(0,0,0,0.45) 1%, rgba(0,0,0,0.8) 100%);
filter: alpha(opacity = 80);
opacity: 0;
@msurguy
msurguy / instructions.js
Created April 11, 2013 06:25
Blueimp image upload + cropping on the server as described in https://github.com/blueimp/jQuery-File-Upload/issues/1314
Hi. To integrate jcrop i used a done callback. This means i add jcrop only after successful upload. In general its look like this: on done you have data object. Data.result is an array of files' information returned from server. For each file (image) you need to create separate cropbox, and initialize jcrop plugin for each cropbox after image was loaded. Than post that data to server and handle croping of image on server side. Well, it's my solution, but there are many another ways.
Code:
var cropbox_indx = 0, //index of cropbox
img_data = {}, // keeps uploaded image data
crop_w = 150,
crop_h = 125;
@msurguy
msurguy / gist:5287280
Created April 1, 2013 19:57
PhoneGap resources
https://github.com/ccoenraets/phonegap-workshop-solutions
http://blog.stevensanderson.com/2011/10/05/full-height-app-layouts-a-css-trick-to-make-it-easier/
@msurguy
msurguy / gist:5287103
Created April 1, 2013 19:30
Using FTP bundle in Laravel
Route::get('ftp', function(){
$ftp = SFTP::make('example.com', 'username', 'password');
// connect to FTP server
if($ftp->connect()) {
print "Connection successful";
// download a file from FTP server
// will download file "somefile.php" and
// save locally as "localfile.php"
@msurguy
msurguy / gist:5287095
Created April 1, 2013 19:29
Using Excel Bundle in Laravel
Route::get('excel', function(){
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->getActiveSheet();
$sheet->setCellValue('A1','Test value');
$writer = new PHPExcel_Writer_Excel5($objPHPExcel);
$writer->save("test.xls");
return Response::download('test.xls', 'test.xls');
});
@msurguy
msurguy / resetpass.php
Created March 27, 2013 01:24
Reset user's password in Laravel 3 through artisan command . Put this file into application/tasks Usage from command line : php artisan resetpass 1 nEwP@SSwOrd Where 1 is user's id and "nEwP@SSwOrd" is the new password
<?php
class Resetpass_Task {
public function run($arguments)
{
$userid = $arguments[0];
$newpass = $arguments[1];
$user = User::find($arguments[0]);
if($user){
@msurguy
msurguy / index.html
Created March 21, 2013 23:45
A CodePen by Maksim Surguy. Wallpaper generator - Dynamically generated wallpaper
<button id="generateBtn">Show Wallpaper</button>
<select id="res">
<option value="1">800x600</option>
<option value="2">1200x800</option>
<option value="3">1600x1200</option>
<option value="4">1920x1600</option>
</select>
<br>
@msurguy
msurguy / routes.php
Created March 14, 2013 01:16
Laravel redirect to last visited page if not logged in
Route::filter('auth', function()
{
if (Auth::guest())
{
// Save the attempted URL
Session::put('pre_login_url', URL::current());
// Redirect to login
return Redirect::to('login');
}