Skip to content

Instantly share code, notes, and snippets.

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

Jefferson Campos foguinhoperuca

🏠
Working from home
View GitHub Profile
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@francescob
francescob / encrypted_credentials_read.rb
Last active June 28, 2021 19:38
access rails 5.2 encrypted credentials from a script outside the rails app
#First of all, require all of rails (maybe it doesn't need to be all, but for now it is)
require 'rails/all'
#then i need to slightly overwrite a rails method:
def encrypted(path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY")
ActiveSupport::EncryptedConfiguration.new(
config_path: path,
key_path: key_path,
@imthatcarlos
imthatcarlos / instructions.txt
Created December 4, 2016 05:04
Create a new rails application with a specific version
# make directory for new rails app
mkdir app
cd app
# specify ruby version
echo 2.3.1 > .ruby-version
# initialize bundler (creates Gemfile)
bundler init
@bishboria
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
@dashed
dashed / github-pandoc.css
Created September 26, 2013 13:42
GitHub-like CSS for pandoc standalone HTML files (perfect for HTML5 output). Based on Marked.app's GitHub CSS. Added normalize.css (v2.1.3) in the prior to GitHub css.
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@chrislkeller
chrislkeller / import_json_appsscript.js
Last active March 25, 2024 19:45
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 3, 2024 16:53
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@alexvbush
alexvbush / run_perl_python_scipts_in_rails.rb
Created July 19, 2011 22:08
How to run Perl and Python scripts in a Rails app.
#This will run Perl and Python scripts respectively in Rails console using 'gem escape'. Gem Escape allows to format path to the scripts properly.
perl_cmd = Escape.shell_command(['perl', "#{RAILS_ROOT}/bin/test_perl_script.pl"]).to_s
system perl_cmd
python_cmd = Escape.shell_command(['python', "#{RAILS_ROOT}/bin/test_python_script.py"]).to_s
system python_cmd
(require 'iimage)
(autoload 'iimage-mode "iimage" "Support Inline image minor mode." t)
(autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t)
(add-to-list 'iimage-mode-image-regex-alist '("@startuml\s+\\(.+\\)" . 1))
;; Rendering plantuml
(defun plantuml-render-buffer ()
(interactive)
(message "PLANTUML Start rendering")
(shell-command (concat "java -jar ~/Downloads/plantuml.jar "