Skip to content

Instantly share code, notes, and snippets.

@JasonTrue
JasonTrue / searchkick_and_elasticsearch_guidance.md
Last active March 7, 2024 14:42
Searchkick and Elastic Search guidance

Resources:

https://github.com/ankane/searchkick

Indexing

By default, simply adding the call 'searchkick' to a model will do an unclever indexing of all fields (but not has_many or belongs_to attributes).

In practice, you'll need to customize what gets indexed. This is done by defining a method on your model called search_data

def search_data

@nitsx2
nitsx2 / puma install error
Created June 28, 2018 07:22
An error occurred while installing puma (3.6.0), and Bundler cannot continue. Make sure that `gem install puma -v '3.6.0'` succeeds before bundling.
sometime puma has problem to install.
Reason -> because of SSL
ERROR--> An error occurred while installing puma (3.6.0), and Bundler cannot continue.
Make sure that `gem install puma -v '3.6.0'` succeeds before bundling.
SOLUTION -> DISABLE_SSL=true gem install puma
Specify the version if you have version specific requirement like:
@kivanio
kivanio / token.rb
Created December 22, 2016 17:53 — forked from GregBaugues/token.rb
Google API OAuth 2.0 refresh token (Ruby on Rails)
# The OAuth access token provided by the Google API expires in 60 minutes. After expiration,
# you must exchange a refresh token for a new access token. Unfortunately, the the Google API
# ruby gem does not include a method for refreshing access tokens.
# You can read up on how to refresh an access token here:
# https://developers.google.com/accounts/docs/OAuth2WebServer#refresh
# This Token model implements that process. It's based off of a Token model that can be created
# by running:
# rails g model Token token:text refresh_token:string expires_at:datetime
@ddaws
ddaws / AdWordsScriptRunner.js
Last active October 16, 2023 06:37
Executes AdWords scripts across 50+ accounts in parallel and sequentially
// the script will run across all accounts with exactly this label. If you want the script to run
// accross all accounts just remove this all together
var SCRIPT_LABEL = 'Your Script!';
function run() {
// your script goes here
}
// this will execute your script sequentially accounts and is only used for accounts in excess of 50
function executeInSequence(sequentialIds, executeSequentiallyFunc) {
@aquach
aquach / amplitude_event.rb
Last active March 26, 2020 17:45
Exports Amplitude data to MySQL
class AmplitudeEvent < ActiveRecord::Base
end
@benjamindean
benjamindean / Code.desktop
Last active July 20, 2019 12:19
Linux desktop entry for Visual Studio Code. Goes to "/usr/share/applications/". For this to work, Code should be linked to `code` executable: https://code.visualstudio.com/Docs/setup
[Desktop Entry]
Name=Code
Exec=code %U
Terminal=false
Icon=code
Type=Application
StartupNotify=true
Categories=TextEditor;Development;Utility;
MimeType=text/plain;
@sergey-alekseev
sergey-alekseev / merge-vs-merge-with-bang.rb
Created March 30, 2015 12:38
Ruby Merge vs. Merge! comparison (benchmarking)
Benchmark.ips do |x|
x.report('merge') { {}.merge :a => 1 }
x.report('merge!') { {}.merge! :a => 1 }
x.compare!
end
Calculating -------------------------------------
merge 34.220k i/100ms
merge! 33.039k i/100ms
-------------------------------------------------
merge 1.923M (±32.2%) i/s - 7.631M
@boodle
boodle / Making Apple Developer certificates on Linux.md
Last active April 8, 2024 12:30
Making Apple Developer certificates on Linux
  1. Create a new directory;
mkdir Apple\ Enterprise
cd Apple\ Enterprise
  1. Generate a certificate signing request
openssl req -nodes -newkey rsa:2048 -keyout ios_enterprise.key -out CertificateSigningRequest.certSigningRequest
@sangeeths
sangeeths / github-to-bitbucket
Created March 10, 2014 15:24
Forking a Github repo to Bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@mhawksey
mhawksey / gist:1276293
Last active October 23, 2023 09:00
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software