Skip to content

Instantly share code, notes, and snippets.

@hanxiao
hanxiao / testRegex.js
Last active November 18, 2024 06:50
Regex for chunking by using all semantic cues
// Updated: Aug. 20, 2024
// Run: node testRegex.js whatever.txt
// Live demo: https://jina.ai/tokenizer
// LICENSE: Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// COPYRIGHT: Jina AI
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
@tmichel
tmichel / project-template.sublime-project
Created December 1, 2019 11:24
Sublime Text 3 Rails+Rspec project config template
{
"folders":
[
{
"path": "/path/to/project",
"folder_exclude_patterns": [
".vscode",
"tmp",
"vendor/bundle",
"log"
@tmichel
tmichel / disable-shift-augmentation.sh
Created January 24, 2018 14:48
Disable annoying shift augmentation for ctrl+up and ctrl+down on macOS
/usr/libexec/PlistBuddy -c "set AppleSymbolicHotKeys:34:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "set AppleSymbolicHotKeys:35:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "set AppleSymbolicHotKeys:37:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
# 34 and 35 might not exists. Add them.
/usr/libexec/PlistBuddy -c "add AppleSymbolicHotKeys:34:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "add AppleSymbolicHotKeys:35:enabled bool false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
# Restart your computer. Log out then log in did not work for me.
@tmichel
tmichel / table_helper.rb
Last active December 29, 2017 11:23
Very simple table_for and attribute_table_for for Rails
# Drop this into app/helpers and then in your views:
#
# <%= table_for(User.all) do |t| %>
# <% t.column :username %>
# <% t.column :email do |user| %>
# <%= mail_to user.email %>
# <% end %>
# <% t.actions :show, :edit %>
# <% end %>
#
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active November 19, 2024 11:06
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@tmichel
tmichel / bash_cheatsheet.md
Created June 16, 2017 12:57
Bash cheat sheet

Shell cheat sheet

Setting up iTerm

  • Use option as meta key:

Go to Preferences->Profiles tab. Select your profile on the left, and then open the Keyboard tab. At the bottom is a set of buttons that lets you select the behavior of the Option key. For most users, Esc+ will be the best choice.

  • Setting up word-by-word movement with Option+:

How to calculate your hourly rate as a freelancer?

Many people struggle with this question. Some just try to make as much as a full-time employee makes (and ignore that they won't be able to bill as many days). Others follow tips on startup related websites that suggest to ask for 20% to 50% more than an salary would yield (and ignore the additional risk and expenses they have).

Below you will find some numbers to help you calculate how high your hourly or daily rate should be.

Your yearly income should be higher than an average salary

  • You take more risk than full time employees, phases without income are likely

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@duffn
duffn / creating_a_date_dimension_table_in_postgresql.sql
Last active October 5, 2024 19:26
Creating a date dimension table in PostgreSQL
DROP TABLE if exists d_date;
CREATE TABLE d_date
(
date_dim_id INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
@danielvamosi
danielvamosi / .rubocop.yml
Created August 2, 2015 15:07 — forked from gdotdesign/.rubocop.yml
DiNa Rubocop Config
AllCops:
RunRailsCops: true
Documentation:
Enabled: false
Style/AlignHash:
Enabled: false
Style/AlignParameters: