Skip to content

Instantly share code, notes, and snippets.

View nathanaelkane's full-sized avatar

Nate Kane nathanaelkane

  • Brisbane, Australia
View GitHub Profile
@JamesYang76
JamesYang76 / Time Zone.md
Last active April 4, 2024 22:00
Time Zone for rails

Time zones

There are trhee diffrent time zones in rails

  • System - The server time zone
  • Application - Rails application use own time zone
  • Database - Default is UTC, but do not change it

Cautions

  • config.time_zone should be set when an app dose not support multiple time zones
  • Do not use Date/Time API using system time zone
  • Date could be incorrect by being converted from datetime or time to date
@jasoncodes
jasoncodes / README
Created September 19, 2018 03:43
JSON bookmarklet
A basic bookmarklet to make JSON readable.
Minified using http://chriszarate.github.io/bookmarkleter/.
@kerryboyko
kerryboyko / README.md
Last active April 26, 2023 16:08
VueJS Best Practices Guide

Deverus Vue.js Style Guide

Guide for developing Vue.js applications.

v. 0.0.1

Vue.js is an amazing framework, which can be as powerful as Angular or React, the two big heavy hitters in the world of front-end frameworks.

However, most of Vue's ease-of-use is due to the use of Observables - a pattern that triggers re-renders and other function calls with the reassignment of a variable.

@romainl
romainl / Vim_pushing_built-in_features_beyond_their_limits.markdown
Last active September 19, 2023 08:16
Vim: pushing built-in features beyond their limits

Vim: pushing built-in features beyond their limits

The situation

Searching can be an efficient way to navigate the current buffer.

The first search commands we learn are usually / and ?. These are seriously cool, especially with the incsearch option enabled which lets us keep typing to refine our search pattern. / and ? really shine when all we want is to jump to something we already have our eyeballs on but they are not fit for every situation:

  • when we want to search something that's not directly there, those two commands can make us lose context very quickly,
  • when we need to compare the matches.
#!/usr/bin/env python
import pynvim, os, re, sys, time
# Get a list of buffers that haven't been deleted. `nvim.buffers` includes
# buffers that have had `:bdelete` called on them and aren't in the buffer
# list, so we have to filter those out.
def get_listed_buffers(nvim):
return set(buf.number for buf in nvim.buffers \
if nvim.eval('buflisted(%d)' % buf.number))
@romainl
romainl / _rnb.md
Last active August 12, 2021 21:56
RNB, a Vim colorscheme template
@hackling
hackling / Explanation.md
Last active August 29, 2015 14:09
How to use FIND and SED together

Combining both find and sed to find and replace words

Example script

find app db spec -type f \( -name '*.rb' -o -name '*.sql' \) -exec sed -i '' -e 's/dollar_value/budget_value/g' {} \;

This script:

  • searches in the app, db, and spec directories
  • it only looks at file types that are either .rb or .sql files
@longlostnick
longlostnick / uploads_controller.rb
Created June 17, 2014 18:20
Rails JSON file upload with carrierwave (from base64 string)
class Api::UploadsController < ApiController
def create
@upload = Upload.new(upload_params)
ensure
clean_tempfile
end
private
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 3, 2024 20:51
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)