Skip to content

Instantly share code, notes, and snippets.

View JulienSansot's full-sized avatar

Julien Sansot JulienSansot

View GitHub Profile
@JulienSansot
JulienSansot / center image in div
Last active November 7, 2017 09:35
center image in div
- 1
the image uses the full width or full height of the div
we always see all the image, nothing is cropped
<div class="container"></div>
.container {
width: 500px;
height: 300px;
border: 1px solid black;
background-image: url("http://placehold.it/200x400");
background-repeat: no-repeat;
@JulienSansot
JulienSansot / ansible playbook for deploying a node app on ubuntu
Created June 3, 2015 06:29
ansible playbook for deploying a node app on ubuntu
---
- hosts: all
remote_user: ubuntu
vars:
app_repo: git@bitbucket.org:****/****.git
app_id: my_app
app_folder: /home/ubuntu/my_app
log_folder: /home/ubuntu/my_app_logs
tasks:
- name: git clone
@JulienSansot
JulienSansot / asynctest_controller.rb
Last active January 16, 2016 00:08
async controller in rails with Thin, EventMachine, em-synchrony, em-http-request
class AsynctestController < ApplicationController
require "em-synchrony/em-http"
def test
EventMachine.synchrony do
http = EventMachine::HttpRequest.new("https://www.google.co.uk/").get
render :json => {result: http.response}
@mahemoff
mahemoff / uniq.rb
Created September 12, 2014 00:29
Ensure Sidekiq jobs are unique (if the queue contains several jobs with same class and args, this will delete all but one of them)
def self.uniq! queue_name
seen_already = Set.new
Sidekiq::Queue.new(queue_name).each { |job|
key = { job.klass => job.args }
key.in?(seen_already) ? job.delete : seen_already << key
}
end
@supereggbert
supereggbert / index.html
Last active October 15, 2023 23:19
3D Surface Plot in D3.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body{
font-family: sans;
padding: 10px;
}
svg path{
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active April 19, 2024 01:50
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@ushu
ushu / S3 buckets copy.md
Created October 29, 2013 16:12
Copy between S3 buckets w/ different accounts

This is a mix between two sources:

basically the first resource is great but didn't work for me: I had to remove the trailing "/*" in the resource string to make it work. I also noticed that setting the policy on the source bucket was sufficient. In the end these are the exact steps I followed to copy data between two buckets on two accounts

Basically the idea there is:

  • we allowe the destination account to read the source bucket (in the console for the source account)
  • we log as the destination and start the copy
public class ಠ_ಠAttribute : Attribute
{
}
[ಠ_ಠ]
public class Manager
{
// 1000s of lines here
}
@jimmynotjim
jimmynotjim / gist:2663844
Created May 12, 2012 02:54 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter