Skip to content

Instantly share code, notes, and snippets.

View richhollis's full-sized avatar

Richard Hollis richhollis

View GitHub Profile
@yairEO
yairEO / jQuery.ajaxRetry.js
Last active January 12, 2022 14:55
jQuery AJAX smart retry
// enhance the original "$.ajax" with a retry mechanism
$.ajax = (($oldAjax) => {
// on fail, retry by creating a new Ajax deferred
function check(a,b,c){
var shouldRetry = b != 'success' && b != 'parsererror';
if( shouldRetry && --this.retries > 0 )
setTimeout(() => { $.ajax(this) }, this.retryInterval || 100);
}
return settings => $oldAjax(settings).always(check)
@sirsquidness
sirsquidness / proxy.conf
Created September 22, 2016 12:42
How to have nginx proxy_pass follow upstream 302 redirects (eg, when you're running a steam cache and you're behind Cox's layer 7 interception stuff)
# This config came around after a friend had problems with a Steam cache on his
# Cox internet connection. Cox would intercept any requests to Steam content
# servers and return a 302 to Cox's servers. The cache would return the 302
# to the Steam client, and the Steam client would go directly to Cox, bypassing
# the cache.
# This config makes nginx follow the 302 itself, and caches the result of the
# redirect as if it was the response to the original request. So subsequent
# requests to the URL that returned a 302 will get the file instead of a 302.
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active April 3, 2024 06:54
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@xrstf
xrstf / letsencrypt.md
Last active April 18, 2023 05:01
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@R3V1Z3
R3V1Z3 / install_future_pinball.sh
Last active January 31, 2020 10:31
A bash script to install Future Pinball on Ubuntu and derivatives like Elementary OS and Linux Mint.Information and further discussion here: http://r3dux.org/2012/02/how-to-configure-future-pinball-to-play-in-linux-through-wine/#comment-7630
#!/bin/bash
# install wine beta, as of 2015-07-13
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7
# install extra libraries needed for FP
winetricks corefonts vcrun6 wsh56
@wenzhixin
wenzhixin / ubuntu14.04-command-line-install-android-sdk
Last active January 16, 2024 21:15
Ubuntu 14.04 command line install android sdk
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@nruth
nruth / pay_stripe_helper.rb
Last active March 7, 2023 00:21
capybara selenium webdriver stripe.js checkout test helper
# -*- encoding : utf-8 -*-
module PayStripeHelpers
# must be used with driver: :selenium (or :sauce?)
def pay_stripe
sleep(0.7) # wait for the js to create the popup in response to pressing the button
within_frame 'stripe_checkout_app' do # must be selenium
# fill_in 'card_number', with: '4242424242424242' no longer works
4.times {page.driver.browser.find_element(:id, 'card_number').send_keys('4242')}
# fill_in 'cc-exp', with: '5/2018' no longer works
@omercs
omercs / Oauth2AzureActiveDirectoryRuby
Last active March 2, 2021 12:21
Oauth2 token from Azure Active Directory in Ruby on Rails project
require 'oauth2'
class WelcomeController < ApplicationController
# You need to configure a tenant at Azure Active Directory(AAD) to register web app and web service app
# You will need two entries for these app at the AAD portal
# You will put clientid and clientsecret for your web app here
# ResourceId is the webservice that you registered
# RedirectUri is registered for your web app
CLIENT_ID = 'b6a42...'
CLIENT_SECRET = 'TSbx..'
@basti
basti / application.rb
Last active March 1, 2021 10:42 — forked from keighl/application.rb
Local Rails 4 assets precompilation using Capistrano 3 and rsync
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@dblock
dblock / capybara_wait_until.rb
Created July 24, 2013 07:38
Re-implementation of Capybara wait_until.
class Capybara::Session
def wait_until(timeout = Capybara.default_wait_time)
Timeout.timeout(timeout) do
sleep(0.1) until value = yield
value
end
end
end