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
@tanaikech
tanaikech / submit.md
Last active May 5, 2024 07:26
Uploading Local Files to Google Drive without Authorization using HTML Form

Uploading Local Files to Google Drive without Authorization using HTML Form

This is a sample script for uploading local file to Google Drive without the authorization using HTML form. A selected file in your local PC using HTML form is uploaded to Google Drive and saved to Google Drive.

When you use this, at first, please deploy Web Apps. The script is doPost() of following scripts.

Script : Google Apps Script

function doPost(e) {
 var data = Utilities.base64Decode(e.parameters.data);
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@0asa
0asa / usage.html
Last active April 18, 2023 15:49 — forked from aloncarmel/randombg.js
A minimal HTML example to grab a random background from unsplash.com using their API and apply to a div.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script>
<script>
function GetRandomBackground()
{
var app_id = 'YOUR_APPLICATION_ID'
var url = 'https://api.unsplash.com/photos/random?client_id=' + app_id;
$.ajax({
url: url,
@a-barbieri
a-barbieri / videos_helper.rb
Last active July 6, 2023 08:21
Rails helper to embed YouTube and Vimeo iframe in view
# Helpers for better embedding and manipulation of videos
# Place this code in app/helpers/videos_helper.rb
# Then from any view you can add:
#
# <%= get_video_iframe('http://the.video.url') %>
#
# Optionally you can add width and height.
#
# <%= get_video_iframe('http://the.video.url', '1600px', '900px') %>
#
@6temes
6temes / mysql_downgrade.txt
Last active February 11, 2024 16:08
Downgrade MySQL version with brew
# Kill rails server and guard
bin/spring stop
brew services stop mysql
brew uninstall mysql
brew install mysql@5.5
brew link mysql@5.5 --force
brew services start mysql@5.5
rbenv uninstall 2.3.3
rbenv install 2.3.3
gem install bundle
@the-bass
the-bass / application.html.erb
Last active April 15, 2020 15:01
Using Google Analytics with Rails 5 and Turbolinks 5. This code is taken from the conversation between @preetpalS and @packagethief on https://github.com/turbolinks/turbolinks/issues/73.
<%# Put this code snippet between the <head></head>-tags in your application layout and %>
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %>
<%# ... %>
<head>
<%# ... %>
<% if Rails.env.production? %>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@mbajur
mbajur / .md
Created April 29, 2016 07:16
How to create small, unique tokens in Ruby

How to create small, unique tokens in Ruby

That is is basically a "fork" of blog article i'm constantly returning to. It seems that the blog is down:

My choice: Dave Bass’s rand().to_s() trick

Dave Bass proposed this which I picked up for my implementation (here for an 8-chars token):

@hateradio
hateradio / html64.rb
Last active April 29, 2024 05:58
ruby image to base64 string
require 'base64'
# converts attached PNGs into base64 strings
# Eg
# <img src="my.png" /> to <img src="data:image/png;base64,..." />
class To64Html
def initialize(path)
# this scrubs emoji sequences from a string - i think it covers all of them
def strip_emoji ( str )
str = str.force_encoding('utf-8').encode
clean_text = ""
# emoticons 1F601 - 1F64F
regex = /[\u{1f600}-\u{1f64f}]/
clean_text = str.gsub regex, ''
@junyuan-qi
junyuan-qi / gist:9503021
Created March 12, 2014 08:34
At.js Emoji
$(function(){
var emojis = [
"smile", "iphone", "girl", "smiley", "heart", "kiss", "copyright", "coffee",
"a", "ab", "airplane", "alien", "ambulance", "angel", "anger", "angry",
"arrow_forward", "arrow_left", "arrow_lower_left", "arrow_lower_right",
"arrow_right", "arrow_up", "arrow_upper_left", "arrow_upper_right",
"art", "astonished", "atm", "b", "baby", "baby_chick", "baby_symbol",
"balloon", "bamboo", "bank", "barber", "baseball", "basketball", "bath",
"bear", "beer", "beers", "beginner", "bell", "bento", "bike", "bikini",