Skip to content

Instantly share code, notes, and snippets.

View FernandoBasso's full-sized avatar

Fernando Basso FernandoBasso

View GitHub Profile

In haskell, `div` is integer only division. code is nice, see?

@FernandoBasso
FernandoBasso / emacs-finding-help.txt
Last active August 11, 2016 20:10
Tips and a summary of most common and useful commands for finding help in Emacs.
━━━━━━━━━━━━━━━━
EMACS SUMMARY
Fernando Basso
━━━━━━━━━━━━━━━━
Table of Contents
─────────────────
@FernandoBasso
FernandoBasso / emacs-lisp-toggle-org-emph.el
Created August 13, 2016 14:27
oggles showing of org mode markup like ~, /, * etc.
(defun my/toggle-org-emph ()
"Toggles showing of org mode markup like ~, /, * etc."
(interactive)
(when (eq major-mode 'org-mode)
(if (and org-hide-emphasis-markers)
(progn
(print "Hiding org-mode emphasis markers")
(setq org-hide-emphasis-markers nil)
(org-mode))
(progn
#!/usr/bin/env bash
# Place where I manipulate files when I an studying my Anki cards
# and need to run quick snippets of code to assert my knowledge of
# the things I am committing to the long-term memory.
temp_study_dir="${HOME}/Public/tempstudyfiles"
if [ ! -d "$temp_study_dir" ] ; then
mkdir --parent "$temp_study_dir"
cd "$temp_study_dir"
@FernandoBasso
FernandoBasso / sql-insert-returning.sql
Created September 17, 2016 14:42
Use of INSERT and RETURNING in pgsql
INSERT INTO images (
post_id
, extension
, position
, created_at)
(SELECT
'13'
, 'jpg'
, COALESCE(MAX(position), 0) + 1
, CURRENT_TIMESTAMP
@FernandoBasso
FernandoBasso / tmux-coding.bash
Last active October 19, 2016 19:13
Just to start tmux with some tabs ready to start coding in a certain directory/project.
#!/usr/bin/env bash
usage() {
printf "\nUsage: ${0##*/} path session\n\n"
printf " path: a path like \`~/projs/foo\`\n"
printf " session: a name for the session tmux will create\n"
}
if (($# < 2)); then
usage
exit 1
@FernandoBasso
FernandoBasso / convert_to_utf8.bash
Last active October 27, 2016 09:51
On the command line, uses `find` and `iconv` to convert certain files from ISO-8859-1 to UTF-8 (make sure the original files are indeed in ISO-8859-1).
#!/usr/bin/bash
find ./ -name '*.php' -o -name '*.html' -o -name '*.css' -o -name '*.js' -type f |
while read file
do
echo " $file"
mv $file $file.icv
iconv -f ISO-8859-1 -t UTF-8 $file.icv > $file
rm -f $file.icv
done
@FernandoBasso
FernandoBasso / temperatures.c
Last active November 19, 2016 22:33
Part of code to solve the "Temperatures" puzzle from codinggame.com
// https://www.codingame.com/training/easy/temperatures
// gcc -std=c99 -Wall -pedantic -o temperatures temperatures.c
// ./temperatures <<< $(cat input.txt)
//
// input.txt
// 9
// 7 22 -99 0 -1 35 -2 +7654 21
#include <stdio.h>
#include <stdlib.h>
@FernandoBasso
FernandoBasso / htdp-bsl-example.rkt
Last active December 20, 2024 18:15
Just to show some stuff that DrRacket inserts (when using htdp/bsl) and that is probably why some things were not working in emacs/geiser/repl.
#lang htdp/bsl
;; #reader(lib "htdp-beginner-reader.ss" "lang")((modname area-tests) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;; Given length of one side of square, produce the area of the square.
(check-expect (area-of-square 3) 3) ;; This test is wrong.
(check-expect (area-of-square 3.2) (* 3.2 3.2))
(define (area-of-square side)
(* side side))
@FernandoBasso
FernandoBasso / org-mode-spreadsheet-calc-time.txt
Last active November 30, 2016 22:19
An example of a formula to alway update the total time in an org-mode table/spreadsheet.
| Date | Time Studied |
|------------------+--------------|
| <2016-11-22 Tue> | 02:30 |
| <2016-11-23 Wed> | 01:00 |
| <2016-11-25 Fri> | 02:00 |
| <2016-11-30 Wed> | 02:00 |
| | |
| | |
| | |
| ... | |