Skip to content

Instantly share code, notes, and snippets.

View neymarsabin's full-sized avatar
🏠
Working from home

Sabin neymarsabin

🏠
Working from home
View GitHub Profile
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@romainl
romainl / Don't use Vim.md
Last active September 6, 2024 13:42
Don't use Vim for the wrong reasons

Don't use Vim

Don't do the crime, if you can't do the time.

-- Anthony Vincenzo "Tony" Baretta

Vim is an amazing text editor. I love it. Really, I wouldn't [organize][organize] a Vim advent calendar if I didn't. But, as amazing as it is, Vim is not for everyone. It can't solve all your problems, or be a TUI version of your favorite IDE, or make you a better programmer, or land you that dream job in the Bay Area. But Vim can help you be more mindful, focused, and efficient, as long as you approach it with the right mindset.

Don't get me wrong, I certainly welcome you to try Vim, but I'm not a proselyte. I don't thrive on newbies. I just want you to use the right tool for the job and not waste your—and anyone's—time on a fruitless quest.

@kigster
kigster / datadog.rb
Created February 21, 2020 22:18
Datadog Rails Configuration
# config/initializers/datadog.rb
require 'ddtrace'
require 'redis'
Datadog::Tracer.log = Logger.new(nil)
# This is the port we have configured in the /etc/datadog/datadog.yml (apm_config)
Datadog.tracer.configure(port: 9126, enabled: true)
# TODO: change me
@virolea
virolea / upload.js
Last active August 28, 2024 02:16
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@daviderestivo
daviderestivo / eshell-prompt.el
Last active July 21, 2019 20:38
Eshell prompt
(defun galactic-emacs-eshell-prompt ()
"Customize eshell prompt.
This function requires `all-the-icons' package to be installed
(https://github.com/domtronn/all-the-icons.el)."
(if (display-graphic-p)
(setq galactic-emacs-header-bg "#282C34")
;; The background used when Emacs runs in a terminal
(setq galactic-emacs-header-bg "black"))
;; In order to set the eshell prompt correctly we need to
@siakaramalegos
siakaramalegos / basic_router.jsx
Last active July 6, 2023 04:02
Basic example of React Router: BrowserRouter, Link, Route, and Switch
// BrowserRouter is the router implementation for HTML5 browsers (vs Native).
// Link is your replacement for anchor tags.
// Route is the conditionally shown component based on matching a path to a URL.
// Switch returns only the first matching route rather than all matching routes.
import {
BrowserRouter as Router,
Link,
Route,
Switch,
} from 'react-router-dom';
@sheharyarn
sheharyarn / api_controller.rb
Last active January 18, 2021 15:13
API Authentication with Devise in Rails
class API::BaseController < ApplicationController
def index
render json: { active: true }
end
def authenticate
if user = User.authenticate(request.headers['X-AUTH-TOKEN'])
sign_in(user, store: false)
@fgilio
fgilio / axios-catch-error.js
Last active August 15, 2024 01:45
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 😨
@preetpalS
preetpalS / dotenv-mode.el
Last active October 30, 2019 22:11
An Emacs major mode for .env files
;;; dotenv-mode.el --- Major mode for .env files -*- lexical-binding: t; -*-
;; Author: Preetpal S. Sohal
;; URL: https://github.com/preetpalS/emacs-dotenv-mode
;; Version: 0.2.5
;; Package-Requires: ((emacs "24.3"))
;; License: GNU General Public License Version 3
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@mankind
mankind / rails-jsonb-queries
Last active July 30, 2024 05:01
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")