Skip to content

Instantly share code, notes, and snippets.

View msurguy's full-sized avatar

Maksim Surguy msurguy

View GitHub Profile
This file has been truncated, but you can view the full file.
'use strict';
var COMPILED = !0, goog = goog || {};
goog.global = this;
goog.DEBUG = !1;
goog.LOCALE = "en";
goog.provide = function (a) {
if (!COMPILED) {
if (goog.isProvided_(a))
throw Error('Namespace "' + a + '" already declared.');
@msurguy
msurguy / DB.sql
Last active March 21, 2025 14:46
Dynamic dropdown in Laravel, let's say you have multiple drop downs (selects), you click on one and the contents of the other need to be dynamically changed. One solution is to dynamically load JSON from the API and change the dropdown dynamically depending on the user choice.
CREATE TABLE `makers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
@msurguy
msurguy / model.php
Created March 11, 2013 19:10
Get created_at date in different formats with Laravel in PHP 5.2+. Put this code in your model (for example models/users.php) and in your views do {{ $user->short_created_at }}
public function get_short_created_at()
{
$date = $this->get_attribute('created_at');
if (is_string($date)){
$dateObject = DateTime::createFromFormat('Y-m-d H:i:s', $date);
return $dateObject->format('Y-m-d');
}
return $date;
}
@msurguy
msurguy / controllerandview.php
Created March 10, 2013 00:48
Using Humane.js in Laravel projects. Sometimes you need to show a nice message to the user after some action is executed. Humane.js (http://wavded.github.com/humane-js/) is designed to show you those nice looking messages with ease.
// inside of a controller call:
Session::flash('status_success', 'Succesfully submitted!');
// inside of your view :
<script>
@if (!is_null(Session::get('status_success')))
@if (is_array(Session::get('status_success')))
@foreach (Session::get('status_success') as $success)
displayMessage('{{$success }}', "success");
@msurguy
msurguy / drag drop backbone jquery UI
Created March 3, 2013 16:26
drag and drop with backbone
$('#overlay-objet img').droppable({
tolerance: 'pointer',
drop: _.bind(function(event, ui) {
object = $(event.target);
if (object.attr("data-val") != undefined){
objectDrag = object.attr('data-val').toString();
objectDrop = $(ui.draggable).attr('data-val').toString();
//$(ui.draggable).removeClass('objet-drag').addClass('objet-hover');
object.addClass('hidden');
$('#'+object.attr('data-toggle')).removeClass('hidden');
@msurguy
msurguy / share on FB, Twitter or Google+
Created February 22, 2013 20:29
Javascript click events to share on FB, twitter or Google +
$('tweet_link').click(function() {
var width = 550;
var height = 420;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
myWindow = window.open("https://twitter.com/share?text=myapp.do%20%7C%20%40FreshBooks%20time%20tracking%20for%20to-dos%3A%20&url=http%3A%2F%2Fmyapp.com%2F&via=myapp", "subWind", windowFeatures);
return false;
});
@msurguy
msurguy / backbone Phonegap Show
Created February 9, 2013 02:41
Backbone PhoneGap animation for elements
Demo.Views.Page = Backbone.View.extend({
className: "page",
initialize: function () {
this.render();
},
show: function () {
$('.page').css({"position": "absolute"});
var direction_coefficient = this.options.back ? 1 : -1;
if ($('.page').length) {
var SomeModel = Backbone.Model.extend({});
someModel = new SomeModel();
someModel.bind("change", function(model, collection){
alert("You set some_attribute to " + model.get('some_attribute'));
});
someModel.set({some_attribute: "some value"});

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@msurguy
msurguy / index.html
Created December 18, 2012 21:12
A CodePen by Maksim Surguy.
<input type="button" id="start" value="Start Life" onclick="life.toggleLife();">
<input type="button" value="Clear" onclick="life.clear();">
<canvas id="universe" width="500" height="500">