Skip to content

Instantly share code, notes, and snippets.

View loicginoux's full-sized avatar

Loic loicginoux

View GitHub Profile
@loicginoux
loicginoux / firebase-messaging-sw.js
Last active January 12, 2024 07:14
Adding FCM to an html page to receive notifications and sending then via FCM ruby gem. (edit: HTTPS needed!)
// [START initialize_firebase_in_sw]
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
@loicginoux
loicginoux / explanation.md
Last active July 1, 2023 11:22
Integrate Bootsy rich text editor with rails admin

Gemfile

gem "rails_admin"
gem 'bootsy'

/app/assets/javascripts/rails_admin/custom/ui.js

@loicginoux
loicginoux / batch update indentation 4 spaces -> 2 spaces
Last active June 22, 2017 09:34
find all html files and change indentation from 4 spaces by 2 spaces
# find all html files in a directory and update indentation
find . -iregex '.*/.*\.html' -exec perl -pi -e 's{^((?: {4})*)}{" " x (2*length($1)/4)}e' {} \;
# update ndentation for one file
perl -pi -e 's{^((?: {4})*)}{" " x (2*length($1)/4)}e' yourfile.js
@loicginoux
loicginoux / gist:6ed431eb9abcdfcb10e0
Created December 15, 2014 12:46
get AWIS - alexa rank from amazon api
BASE_URL = "http://awis.amazonaws.com/"
access_key_id = AppConfig.get_value('aws_access_key_id')
secret_access_key = AppConfig.get_value('aws_secret_access_key')
now = Time.now.utc.iso8601
url = "yahoo.com"
query = {'AWSAccessKeyId' =>access_key_id,
'Action' => "UrlInfo",
'ResponseGroup' => "Rank",
'SignatureMethod' => "HmacSHA1",
'SignatureVersion' => 2,
@loicginoux
loicginoux / yahoo_boss_test_api.rb
Created August 20, 2014 11:03
yahoo boss test api
require 'net/http'
include HTTParty
# test app
YAHOO_CONFIG = {
client_id: "YOUR APP ID",
client_secret: "YOUR APP SECRET"
}
@loicginoux
loicginoux / testing authorisation flow with doorkeeper
Created May 29, 2014 11:51
testing authorisation flow with doorkeeper
require 'oauth2'
client_id = '...'
client_secret = '...'
redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
site = "http://localhost:3000"
client = OAuth2::Client.new(client_id, client_secret, :site => site)
# client.auth_code.authorize_url(:redirect_uri => redirect_uri)
##########################################
# Use cases:
# setting a config variable: Variable[:my_key] = 1
# getting a config variable: Variable[:my_key]
# retrieving all keys: Variable.keys
# deleting a key: Variable.delete!(:my_key)
# checking existence: Variable.exists?(:my_key)
# clear all keys: Variable.clear!
#
# Values are transformed to yaml before stored
@loicginoux
loicginoux / gist:5577498
Created May 14, 2013 16:50
paste this into your app/assets/stylesheets/active_admin.css.scss to get Rich editor styling correct in Active Admin
body.active_admin {
.cke_chrome {
width: 76% !important;
overflow: hidden;
}
.cke_dialog_background_cover{
background-color: black !important;
}
}
body.active_admin {