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 / _base.css
Last active July 9, 2021 10:30
webprojects-utilities
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 16px;
# in .bahrc replace this:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
@mayinx
mayinx / ruby-benchmarking.sh
Last active January 23, 2020 20:42
Easy Ruby-Benchmarking
# Easy Ruby-Benchmarking, e.g
require 'benchmark'
n = 10_000
Benchmark.bm do |benchmark|
benchmark.report("settings") do
n.times do
d.settings(:themes).value
@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