Skip to content

Instantly share code, notes, and snippets.

@xocasdashdash
xocasdashdash / infinite-scroll.js
Created August 24, 2014 13:42
Simple infinite scrol with jQuery and a Symfony2 backend
is_processing = false;
last_page = false;
function addMoreElements() {
is_processing = true;
$.ajax({
type: "GET",
//FOS Routing
url: Routing.generate('route_name', {page: page}),
success: function(data) {
if (data.html.length > 0) {
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@scmx
scmx / upgrade-install-ruby-2-1-2-ubuntu-12-04.md
Last active November 6, 2019 15:31
Upgrade/Install ruby 2.1.2 #ubuntu #12.04 #14.04

Upgrade/Install ruby 2.1.2

ubuntu 12.04 14.04

Reference http://stackoverflow.com/a/18490935/2037928

Login as root

Install needed packages

apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
@paulund
paulund / wordpress-base-custom-data.php
Created September 24, 2013 16:27
A PHP class to handle CRUD functionality in WordPress default tables.
<?php
/**
* Abstract class which has helper functions to get data from the database
*/
abstract class Base_Custom_Data
{
/**
* The current table name
*
* @var boolean
@rponte
rponte / simple_method.js
Last active June 11, 2016 09:13
Delaying actions on keypress with jQuery
$('#mySearch').keyup(function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 500);
$(this).data('timer', wait);
});
function search() {
$.post("stuff.php", {nStr: "" + $('#mySearch').val() + ""}, function(data){
if(data.length > 0) {
$('#suggestions').show();
@bigcalm
bigcalm / fail_demo.html.twig
Created February 6, 2013 14:38
Using Symfony2, DQL and knplabs/knp-paginator-bundle - how to get around "Cannot count query which selects two FROM components, cannot make distinction"
<ul>
{% for project in pagination %}
<li>{{ project.name }} has {{ project.?? }} tasks</li>
{% endfor %}
</ul>