Skip to content

Instantly share code, notes, and snippets.

View GGrassiant's full-sized avatar
:octocat:
Continuously learning

Guillaume Grassiant GGrassiant

:octocat:
Continuously learning
View GitHub Profile
function * fibonacci(seed1, seed2) {
while (true) {
yield (() => {
seed2 = seed2 + seed1;
seed1 = seed2 - seed1;
return seed2;
})();
}
}
@ssaunier
ssaunier / user_binding.json
Created December 3, 2017 21:10
Sublime Key Bindings for using Emmet inside Babel JavaScript files. Sublime > Preferences > Key Bindings
[
{ "keys": ["tab"], "command": "expand_abbreviation_by_tab", "context":
[
{ "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" },
{ "match_all": true, "key": "selection_empty" },
{ "operator": "equal", "operand": false, "match_all": true, "key": "has_next_field" },
{ "operand": false, "operator": "equal", "match_all": true, "key": "auto_complete_visible" },
{ "match_all": true, "key": "is_abbreviation" }
]
}
@TsaiKoga
TsaiKoga / rails_bulk_rename_columns.rb
Last active June 30, 2021 19:16
Ruby on Rails rename columns in bulk
class RenameOldOrderAddressRelatedColumn < ActiveRecord::Migration
def up
change_table(:orders, :bulk => true) do |t|
t.rename :order_status_code_id, :state
t.remove :in_process
[:first_name,
:last_name,
:country,
:state].each do |column|
t.rename "shipping_#{column}", "origin_shipping_#{column}"
@fgilio
fgilio / axios-catch-error.js
Last active June 18, 2025 11:09
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active July 7, 2025 21:06
React Native Bridging Cheatsheet
@cdm
cdm / gist:bce25582f796c96236c3625adbcba36f
Created February 9, 2017 10:24
React-Native Default Fonts
To use in react-native, choose from font below, and then add to style element:
<Text style={{ fontFamily: 'Arial' }}>Arial Font</Text>
Alternatively, add your own custom font face
Android:
========
normal
@paulsturgess
paulsturgess / service.js
Last active August 8, 2024 04:25
An example Service class wrapper for Axios
import axios from 'axios';
class Service {
constructor() {
let service = axios.create({
headers: {csrf: 'token'}
});
service.interceptors.response.use(this.handleSuccess, this.handleError);
this.service = service;
}
@tomysmile
tomysmile / mac-setup-redis.md
Last active July 10, 2025 21:05
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@jarretmoses
jarretmoses / React Native Clear Cache
Last active April 23, 2025 11:20
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@arjunvenkat
arjunvenkat / gist:1115bc41bf395a162084
Last active January 12, 2024 05:04
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.