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
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@paulmillr
paulmillr / active.md
Last active May 15, 2024 02:25
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user => user.followers > 1000)
@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
});
};
@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');
@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
@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}"
# 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
#
@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.

@adamjohnson
adamjohnson / publickey-git-error.markdown
Last active June 8, 2024 15:32
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
@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>