Skip to content

Instantly share code, notes, and snippets.

View ryzalyusoff's full-sized avatar
🛠️
Building Reader Mode

Ryzal Yusoff ryzalyusoff

🛠️
Building Reader Mode
View GitHub Profile
@miyagawa
miyagawa / README.md
Last active March 2, 2020 21:03
Gumroad Sales widget for dashing.

Displays last 30 day sales for Gumroad on Dashing. Doesn't use API since the data doesn't appear to be provided.

Screenshot

Configuration

Set GUMROAD_USERNAME qnd GUMROAD_PASSWORD enviroment variable.

@zolzaya
zolzaya / kaminari_load_more.md
Last active February 2, 2021 02:01
Most easy "load more" behavior implementation for Kaminari.

In your view:

<%= link_to "Load more", posts_path(@posts, page: @posts.current_page+1), id: "load-more-posts", remote: true %>

In your controller:

respond_to :html, :js, only: [:index]

def index
@andyj
andyj / html_for_international_calling coes.htm
Created October 22, 2013 21:57
HTML <select> international calling codes for each country
<!-- country codes (ISO 3166) and Dial codes. -->
<select name="countryCode" id="">
<option data-countryCode="GB" value="44" Selected>UK (+44)</option>
<option data-countryCode="US" value="1">USA (+1)</option>
<optgroup label="Other countries">
<option data-countryCode="DZ" value="213">Algeria (+213)</option>
<option data-countryCode="AD" value="376">Andorra (+376)</option>
<option data-countryCode="AO" value="244">Angola (+244)</option>
<option data-countryCode="AI" value="1264">Anguilla (+1264)</option>
<option data-countryCode="AG" value="1268">Antigua &amp; Barbuda (+1268)</option>
@adamjohnson
adamjohnson / publickey-git-error.markdown
Last active May 30, 2024 18:06
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@runlevel5
runlevel5 / how_to_detect_browser_agent_and_redirect_to_warning_page.md
Last active December 15, 2019 00:43
How to detect browser and redirect to a warning page with Ruby On Rails

How to detect browser and redirect to a warning page with Ruby On Rails

There are many ways to detect browser agent, it could be front-end side with Javascript or backend. In this short tutorial, I'll walk you through on how to detect browser version with Ruby On Rails

This applies for Rails > 2.x

How does thing work?

When you surf the site, your browser name and versions are stored in HTTP_USER_AGENT in the request. We need to process this string to work out the browser version and name to decide to greet viewers with warning text or not.

# gem install crack rest-client fastercsv
require 'rubygems'
require 'crack'
require 'rest_client'
require 'fastercsv'
# To use, get an access token here, by clicking "get access token"
# and checking user.groups in the dialog box
# https://developers.facebook.com/tools/explorer?method=GET&path=209024949216061%2Ffeed
#
@abhishek77in
abhishek77in / backup.rake
Last active April 13, 2021 00:09 — forked from rantoniuk/backup.rake
Rake task for backing up MySQL database to AWS-S3 in Rails Application
namespace :db do desc "Backup database to AWS-S3"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
backup_filename = "#{Rails.root.basename}-#{datestamp}.sql"
db_config = ActiveRecord::Base.configurations[Rails.env]
# process backup
`mysqldump -u #{db_config['username']} -p#{db_config['password']} -i -c -q #{db_config['database']} > tmp/#{backup_filename}`
`gzip -9 tmp/#{backup_filename}`
puts "Created backup: #{backup_filename}"
@waynegraham
waynegraham / continentCodes.txt
Created October 22, 2012 16:08
Download and import geonames data
AF,Africa,6255146
AS,Asia,6255147
EU,Europe,6255148
NA,North America,6255149
OC,Oceania,6255151
SA,South America,6255150
AN,Antarctica,6255152
@UnquietCode
UnquietCode / gist:3711511
Created September 13, 2012 02:46
Extract tweet info from the basic Twitter timeline widget.
<html>
<head>
<script type="text/javascript" src="jquery-1.8.1.min.js"></script>
<script type="text/javascript">
<!-- use the url that your twitter widget is using to retrieve the tweet data -->
$(function() {
$.getJSON("http://cdn.syndication.twimg.com/widgets/timelines/246079887021051904?dnt=true&domain=unquietcode.com&lang=en&callback=?", function(data) {
var tweets = $(data.body).find('li.tweet');
@ksafranski
ksafranski / getScript-w-cache.js
Created June 14, 2012 13:02
Replacement for the jQuery $.getScript function with caching
$.getScript = function(url, callback, cache){
$.ajax({
url: url,
dataType: 'script',
success: callback,
cache: cache
});
};