Skip to content

Instantly share code, notes, and snippets.

@mayinx
mayinx / axios-catch-error.js
Created October 26, 2021 15:43 — forked from fgilio/axios-catch-error.js
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 😨
@mayinx
mayinx / rails-4-concern.sublime-snippet
Created October 5, 2018 11:03 — forked from xiy/rails-4-concern.sublime-snippet
A sublime text editor snippet to quickly create a new Rails Concern
<snippet>
<content><![CDATA[module ${1:${TM_FILENAME/(?:\A|_)([A-Za-z0-9]+)(?:\.rb)?/(?2::\u$1)/g}}
extend ActiveSupport::Concern
included do
$2
end
end]]></content>
<tabTrigger>mod</tabTrigger>
<scope>source.ruby, source.ruby.rails, source.rails</scope>
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@mayinx
mayinx / media-query.css
Created December 21, 2017 10:32 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@mayinx
mayinx / rails_load_path_tips.md
Created October 12, 2017 00:16 — forked from maxim/rails_load_path_tips.md
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@mayinx
mayinx / regex-console.text
Created July 20, 2017 14:45
Remove all console.log from JS in Sublime
Ensure regex button is selected and then type this in the search field.
\s*console\.log(.*);
@mayinx
mayinx / main_helper.rb
Created December 1, 2016 10:21 — forked from owen2345/main_helper.rb
Perspective Theme (one click install). Template url: https://p.w3layouts.com/demos/perspective/web/index.html
module Themes::PerspectiveTheme::MainHelper
def self.included(klass)
klass.helper_method [:perspective_social_networks] rescue "" # here your methods accessible from views
end
def perspective_theme_settings(theme)
# callback to save custom values of fields added in my_theme/views/admin/settings.html.erb
end
# callback called after theme installed
@mayinx
mayinx / filterable.rb
Created August 22, 2016 14:20 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
@mayinx
mayinx / sublime-text-2-settings-rails-dev.json
Last active August 29, 2015 14:06 — forked from olivierlacan/sublime-text-2-settings.json
Basic Sublime Text 2 settings for Rails development
{
// use customized monokai color scheme (created with the awesome
// tmtheme-editor - see http://tmtheme-editor.herokuapp.com)
"color_scheme": "Packages/User/MonokaiCustomized2.tmTheme",
"ensure_newline_at_eof_on_save": false,
"use_simple_full_screen": false,
// glasses are expensive, protect your eyesight