Skip to content

Instantly share code, notes, and snippets.

@arielcr
arielcr / share.js
Last active December 19, 2015 20:19
Sharing Links
/*
* Share on Facebook
*/
$('#facebook-Link').click(function () {
var sharer = "https://www.facebook.com/sharer/sharer.php?u=";
window.open(sharer + location.href, 'sharer', 'width=626,height=436');
});
/*
* Share on Twitter
@arielcr
arielcr / fbshare.html
Last active April 22, 2019 10:23
How to pass custom parameters to a Facebook Share button
<a id="facebook-Link"
href="http://www.facebook.com/sharer.php?
s=100
&p[url]=the url you want to share
&p[images][0]=the image you want to share
&p[title]=the title you want to share
&p[summary]=the description/summary you want to share"
target="_blank">
<img src="your/path/to/facebook-icon.png"
alt="Share on Facebook" />
@arielcr
arielcr / embed.html
Created July 17, 2013 17:48
Embed script using javascript
<!-- Embed -->
<div id="my-embed-content"></div>
<script>(function(d, s, id) {
var my_account = 123;
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//the.location.of/my/embed.js#acc="+my_account+"&w=900&h=700";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'my-embed'));</script>
@arielcr
arielcr / embed.js
Created July 17, 2013 17:52
The embed.js script
function parseQuery ( query ) {
var Params = new Object ();
if ( ! query ) return Params;
var Pairs = query.split(/[;&]/);
for ( var i = 0; i < Pairs.length; i++ ) {
var KeyVal = Pairs[i].split('=');
if ( ! KeyVal || KeyVal.length != 2 ) continue;
var key = unescape( KeyVal[0] );
var val = unescape( KeyVal[1] );
val = val.replace(/\+/g, ' ');
@arielcr
arielcr / ror-provisioning.sh
Last active September 30, 2020 00:14
Ruby on Rails Provisioning Script
#!/bin/bash
echo Provisioning Ruby on Rails...
echo =================================
echo - Installing dependencies
sudo apt-get update -y -qq > /dev/null
sudo apt-get install curl -y -qq > /dev/null
echo - Installing mysql server
export DEBIAN_FRONTEND=noninteractive
@arielcr
arielcr / Vagrantfile
Last active April 11, 2016 23:05
Vagrant file for Ruby on Rails
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.provision "shell", path: "https://gist.githubusercontent.com/arielcr/8845938/raw/b95e82166b24728df0d91b31dab9a65eed6cd01f/ror-provisioning.sh"
@arielcr
arielcr / 0_reuse_code.js
Created May 6, 2014 17:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@arielcr
arielcr / populate_select_box.js
Created May 6, 2014 17:44
Populate select box from JSON
$.getJSON('select.php', {customerId: $(this).val()}, function(data){
var vehicle = $('#vehicle');
for (var x = 0; x < data.length; x++) {
vehicle.append(new Option(data[x].reg, data[x].id));
}
});
@arielcr
arielcr / allow-origin.php
Created September 8, 2014 16:52
Laravel filter to allowOrigin
Route::filter('allowOrigin', function($route, $request, $response)
{
$response->header('access-control-allow-origin','*');
});
@arielcr
arielcr / gist:78be4e41d7a9eaf87cf2
Created January 27, 2016 23:09
rsync with server
rsync -av /local/path/ root@xx.xx.xx.xx:/remote/path/