Skip to content

Instantly share code, notes, and snippets.

View victorbstan's full-sized avatar

Victor Stan victorbstan

  • Toronto & Remote
View GitHub Profile
@victorbstan
victorbstan / paperclip_image_dimensions_validation.rb
Created November 23, 2011 01:21
Paperclip Validate minimum image dimensions
validate :check_dimensions
def check_dimensions
temp_file = background_image.queued_for_write[:original]
unless temp_file.nil?
dimensions = Paperclip::Geometry.from_file(temp_file)
width = dimensions.width
height = dimensions.height
if width < 800 && height < 600
@victorbstan
victorbstan / clips.html
Created August 25, 2012 20:34
Angular JS and Rails 3 Infinite Scroll Pagination
<!--
This is the HTML portion of the infinite scroll/pagination with Rails and AngularJS tutorial
Required libraries for the tutorial and indicated as "Important",
together with implementation specific libraries marked as "Optional"
-->
<!DOCTYPE html>
<html>
<title>Clips</title>
<!-- Important -->
@victorbstan
victorbstan / snippets.cson
Created September 2, 2016 15:05
"Verbatim" Atom snippet for Twig templates
'.text.html.twig':
'Verbatim':
'prefix': 'verbatim'
'body': '{% verbatim %}$1{% endverbatim %}$2'
@victorbstan
victorbstan / index.html
Last active December 24, 2015 18:59
Detecting gamepads in Chrome Canary
<html>
<head>
<title>Get Gamepads</title>
</head>
<body>
<!-- adapted from http://stackoverflow.com/questions/10839310/html5-gamepad-api-on-chrome -->
<script>
function updateStatus() {
window.webkitRequestAnimationFrame(updateStatus);
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="author" content="Victor Stan">
<meta name="description" content="Get multiple video streams on one page. Adapted from code by Muaz Khan">
<title>Video Camera</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" ></script>
@victorbstan
victorbstan / profile_photop.rb
Created June 14, 2013 02:49
A module for defaulting to a gravatar image when your profile's own paperclip image isn't available.
require 'digest/md5'
module ProfilePhoto
def profile_photo(profile)
profile.avatar.url(:thumb).present? ? profile.avatar.url(:thumb) : "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(profile.owner.email)}?d=mm"
end
end
# in your application_helper use:
# module ApplicationHelper
@victorbstan
victorbstan / webScraperTest.st
Created March 20, 2013 02:57
Quick and dirty test web scraper in Smalltalk (Pharo2). Simply put it in a "workspace" and "do it". The response output is sent to a "Transcript" window.
| myHost myPath |
"setup"
myHost := 'rmod.lille.inria.fr'.
myPath := '/pbe2'.
ZnClient new
systemPolicy;
accept: ZnMimeType textHtml;
http;
@victorbstan
victorbstan / application.css.scss
Last active December 14, 2015 10:38
Overriding will_paginate gem to provide a drop-down select html tag list for all the page.
.pagination {
display:inline-block;
form {
display: inline-block;
margin:0;
select {
width:100px;
}
}
}
@victorbstan
victorbstan / angular_vs_jquery.js
Created July 8, 2012 02:36
AngularJS vs JQuery for basic GET POST AJAX API
var DOMAIN = 'http://localhost'
var PORT = 3000;
var DATA_SOURCE = '/clips.json';
// ANGULAR
function clips_controller($scope, $http) {
$scope.clips = [];
// get the data from the API backend
$http.get(DOMAIN+":"+PORT+DATA_SOURCE).success(function(data) {
var html5rocks = {};
var indexedDB = window.indexedDB || window.webkitIndexedDB ||
window.mozIndexedDB;
if ('webkitIndexedDB' in window) {
window.IDBTransaction = window.webkitIDBTransaction;
window.IDBKeyRange = window.webkitIDBKeyRange;
}
html5rocks.indexedDB = {};