Skip to content

Instantly share code, notes, and snippets.

function a = lsa(fun,x,d,a1,varargin)
% a = lsa(fun,x,d,a1)
%
% Implementation of Line Search Algorithm with Strong Wolfe conditions
% as found J. Nocedal, S. Wright, Numerical Optimization, 1999 edition
% Algorithm 3.2 on page 59
%
% Output arguments:
% a : final stepsize
%
# `sed -i 's/<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>/
#<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\n
# <meta http-equiv="Content-Type" content="text\/html; charset=UTF-8"\/>/g' #{filename}`
#out = `find . -name "*.htm*" | xargs file -i`
if ARGV.size > 0
out = `file -i #{ARGV[0]}/*.htm*`
else
out = `file -i *.htm*`
@Heliosmaster
Heliosmaster / recode_to_utf8.rb
Created April 28, 2012 10:26
Recode to UTF-8
#out = `find . -name "*.htm*" | xargs file -i`
out = (ARGV.size > 0 ? `file -i #{ARGV[0]}/*.htm*` : `file -i *.htm*`)
out.split("\n").each do |l|
l =~ /(.*):(.*)charset=(.*)/
filename = "#{$1}"
charset = "#{$3}"
charset = "windows-1252" if charset == "unknown-8bit"
if (charset!= "binary" && charset != "us-ascii" && charset != "utf-8")
succ = system("iconv -f #{charset} -t utf-8 #{filename} -o #{filename}.tmp")
if !succ
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
fib0 := 1
fib1 := 1
return func() int {
@Heliosmaster
Heliosmaster / simple_sieve.go
Created September 8, 2012 17:27
Simple Erathostenes' Sieve in Go
package main
import (
"fmt"
"os"
"math"
"strconv"
)
func main(){
// figures out which number is the bound
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
extern double drand48();
int Z;
int M;
int sizeLattice;
int N;
class Something
include DataMapper::Resource
property :id, Serial
property :value, Float, :required => true
property :date, Date, :required => true, :unique => true
property :user, Integer
validates_within :value, :set => (0..200)
end

Keybase proof

I hereby claim:

  • I am heliosmaster on github.
  • I am davide (https://keybase.io/davide) on keybase.
  • I have a public key whose fingerprint is A69F 6A4A B256 ADBE 3342 D1E0 8BF1 0214 1E71 40D0

To claim this, I am signing this object:

[RF12demo.12] B i2 g212 @ 868 MHz
Available commands:
<nn> i - set node ID (standard node ids are 1..30)
<n> b - set MHz band (4 = 433, 8 = 868, 9 = 915)
<nnnn> o - change frequency offset within the band (default 1600)
96..3903 is the range supported by the RFM12B
<nnn> g - set network group (RFM12 only allows 212, 0 = any)
<n> c - set collect mode (advanced, normally 0)
(ns nonograms-dojo.core)
;; Nonograms by Davide Taviani and Boris Arkenaar
(defn transpose [m]
(apply mapv vector m))
(def input-data
{:size [10 10]
:rows [[] [1 1] [1] [2 1 1] [1 1 1] [1 2 1 1] [1] [1] [] []]
:cols [[] [1] [] [3] [1 1] [] [5] [1] [1 4] []]})