Skip to content

Instantly share code, notes, and snippets.

View alcidesfp's full-sized avatar

Alcides Flores Pineda alcidesfp

View GitHub Profile
@alcidesfp
alcidesfp / ui-tweaks.el
Created March 29, 2016 17:11
UI Tweaks for Emacs 24
;;; UI Tweaks
;; nice scrolling
(setq scroll-margin 0
scroll-conservatively 1000
scroll-preserve-screen-position t)
;; enable y/n answers
(fset 'yes-or-no-p 'y-or-n-p)
;; more useful frame title, that show either a file or a
;; buffer name (if the buffer isn't visiting a file)
@alcidesfp
alcidesfp / md5-file-checksum.scm
Last active December 13, 2022 19:09
Kawa: File checksum with MD5
(define-alias FileInputStream java.io.FileInputStream)
(define-alias MessageDigest java.security.MessageDigest)
(define-alias Integer java.lang.Integer)
(require 'srfi-13)
;;--------------------------------------------------------------------
(define (md5vector file-name ::java.lang.String)
(let ((md (MessageDigest:getInstance "MD5"))
(fis (FileInputStream file-name))
(data-bytes ::byte[] ((primitive-array-new byte) 1024)))
(do ((nread 0 (*:read fis data-bytes)))
@alcidesfp
alcidesfp / read-properties.scm
Last active August 29, 2015 14:04
Kawa: Load a properties file
":"; exec kawa -f $0 "$@" #-*- coding:utf-8 -*-
(define-alias Properties java.util.Properties)
(define-alias FileInputStream java.io.FileInputStream)
(let ((props (Properties)))
(props:load (FileInputStream "application.properties"))
(format #t "Nombre: ~A~%" (props:getProperty "app.name"))
(format #t "Version: ~A~%" (props:getProperty "app.version")))
@alcidesfp
alcidesfp / gist:95f32461b78bbf109fe2
Last active August 29, 2015 14:04
Respalda carpeta actual en Kawa
":"; exec kawa -f $0 "$@" # -*- coding:utf-8; mode:Scheme -*-
(define-alias File java.io.File)
(define-alias Date java.util.Date)
(define-alias DateFormat java.text.SimpleDateFormat)
(let* ((this-dir (path-last (*:getCanonicalPath (File "."))))
(backup-date (*:format (DateFormat "yyyyMMdd-HHmm") (Date)))
(nom-tar (format #f "~A_~A.tar" this-dir backup-date)))
(format #t "Generando respaldo ~A ...~%" nom-tar)
@alcidesfp
alcidesfp / gist:8100459
Created December 23, 2013 16:51
Snippet de código en Kawa con Swing
;; -*- coding: utf-8; mode: Scheme -*-
;; Snippet de código utilizando Swing en Kawa
(define-alias JFrame javax.swing.JFrame)
(define-alias JLabel javax.swing.JLabel)
(let ((frame1 (JFrame "Ventana Hola")))
(*:add frame1 (JLabel "Hola a todos desde Kawa"))
(*:pack frame1)
(*:setDefaultCloseOperation frame1 JFrame:EXIT_ON_CLOSE)
(*:setVisible frame1 #t))
//-*- coding:utf-8; -*-
def edad
def nombre
def brin = new BufferedReader(new InputStreamReader(System.in))
def num
print("Hola, ¿Cuál es tu nombre? ")
nombre = new String(brin.readLine())
print("¿En qué año naciste? ")
@alcidesfp
alcidesfp / nomedad.java
Created December 20, 2013 19:41
Programa mascota en Java
import java.io.*;
class nomedad {
public static void main (String[] args) throws IOException {
Integer edad;
String strnombre;
BufferedReader brin;
int n;
/* Inicialización */
brin = new BufferedReader(new
InputStreamReader(System.in));
#!/usr/bin/perl -w
print "Hola ¿Cual es tu nombre?: ";
chomp(my $nombre = readline);
print "¿En que año naciste?: ";
chomp(my $ann = readline);
print "Hola $nombre.\n";
print "En el año 2014 tendrás ", (2014-$ann), " años.\n";
main = do
putStrLn "¡Hola!, ¿Cuál es tu nombre?"
nombre <- getLine
putStrLn "¿En qué año naciste?"
ann_nac <- getLine
let edad = 2014 - (read ann_nac)::Integer
putStrLn ("Hola " ++ nombre)
@alcidesfp
alcidesfp / string_calc.scm
Last active November 14, 2016 16:22
String Calculator en Kawa
; -*- coding: utf-8; mode: Scheme -*- Kawa
;; Coding Kata String Calculator (http://osherove.com/tdd-kata-1/)
(require 'srfi-1 ) ;; List Library
(require 'srfi-13) ;; String Library
(require 'srfi-14) ;; Character-set Library
(define-alias String java.lang.String)
(define-alias RuntimeException java.lang.RuntimeException)