This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pickle | |
| PRIMEFILE = 'primes.pkl' | |
| UPPERLIMIT = 1_000_000 | |
| # This script finds Goldbach pairs for odd numbers starting from the last prime found. | |
| # It uses a brute-force method to find the pairs. | |
| # It also serializes the primes found to a file for future use. | |
| # The script will continue from the last prime found in the file. | |
| # It will also handle exceptions and save the state of the primes to a file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -w | |
| # unescape.pl | |
| # | |
| # Copyright (C) 2007 Guido De Rosa <job at guidoderosa dot net> | |
| # Many thanks to Peter Jakobi for contributions and improvements | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a | |
| # copy of this software and associated documentation files (the "Software"), | |
| # to deal in the Software without restriction, including without limitation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Choose a temperature only at one of the three measurement scales, leave the other two "undefined". | |
| let celsius = undefined | |
| let fahrenheit = undefined | |
| let kelvin = 300 | |
| function cToF() { | |
| return celsius * 9/5 + 32 | |
| } | |
| function cToK() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| N=8 | |
| 6**N | |
| dices = [1]*N | |
| n = 1 | |
| while dices != [6]*N: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'digest/sha1' | |
| 0.upto(1000).each do |i| | |
| s = i.to_s | |
| digest = Digest::SHA1.hexdigest(s) | |
| fg = digest[0..5] | |
| fg_ = {} | |
| fg_[:r] = fg[0..1] | |
| fg_[:g] = fg[2..3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Put this in /etc/udev/rules.d/automount.rules | |
| # | |
| # ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N" | |
| # All based on: | |
| # https://wiki.archlinux.org/index.php/USB_Storage_Devices | |
| # But: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'securerandom' | |
| avg = nil | |
| 0.upto(1000) do |k| | |
| n = 0 | |
| places = {} | |
| loop do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'thin' | |
| require 'sinatra' | |
| # by Guido De Rosa, guido.derosa at vemarsas.it, 2012, distributed under the | |
| # same licensing conditions of jqueryFileTree. | |
| # Based on connectors/jqueryFileTree.rb contained in | |
| # labs.abeautifulsite.net/archived/jquery-fileTree/jquery.fileTree-1.01.zip | |
| # An adaptation from CGI to Sinatra. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| see also | |
| http://wiki.micasaverde.com/index.php/UI_Simple | |
| http://jsoneditor.net/ | |
| http://jsonviewer.stack.hu/ | |
| Assuming IP = 192.168.33.155 | |
| Get devices etc. (simplified) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WIDTH = 20 # Copyright (C) 2011, Guido De Rosa; License: MIT | |
| histogram = Array.new(1 + WIDTH, 0) | |
| 2800.times do | |
| x = WIDTH/2 | |
| WIDTH.times { x += (rand <=> 0.5)/2.0 } # random-walk | |
| histogram[x] += 1 | |
| end | |
| histogram.each_with_index do |bar_value, i| | |
| printf "%02d ", i; (bar_value.to_f/10).ceil.times {print '|'}; puts | |
| end |
NewerOlder