View gcd.fth
This file contains 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
\ This implements Euclidean algorithm in Forth | |
: gcd ( X Y ) | |
2dup <= if swap ( Y X ) then | |
( X Y ) | |
begin | |
tuck ( Y X Y ) | |
mod ( Y Z ) | |
dup ( Y Z Z ) | |
0= until ( Y Z ) | |
( Y 0 ) |
View modulo.hpp
This file contains 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
#include <stdexcept> | |
template<typename T> T modulo(T dividend, T divisor) { | |
if (divisor == static_cast<T>(0)) // division by zero is not allowed | |
throw std::domain_error("division by zero"); | |
if (dividend < static_cast<T>(0)) // dividend is negative | |
return -((-dividend) % (-divisor)); | |
else // dividend is non-negative | |
return dividend % divisor; | |
} |
View groovy.spec
This file contains 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
%define groovy_root_dir /usr/share | |
Name: groovy | |
Version: 2.2.2 | |
Release: 1%{?dist} | |
License: See: http://groovy.codehaus.org/license.html | |
BuildRoot: %{_tmppath}/%{name}-%{version}-build | |
Group: Development/Languages/Groovy | |
Summary: Contains the base system for executing groovy scripts. | |
Source: http://dist.codehaus.org/groovy/distributions/groovy-binary-%{version}.zip |
View gcd.lua
This file contains 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
function gcd(a, b) | |
local x = a; local y = b | |
repeat | |
if x > y then | |
x = math.fmod(x, y) | |
else | |
y = math.fmod(y, x) | |
end | |
until x == 0 or y == 0 | |
return x + y |
View gpufan.bash
This file contains 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 | |
# Script to control the fan speed automatically | |
setFanSpeed() { | |
eval "nvidia-settings -a GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=$1 > /dev/null" | |
} | |
cleanup() { | |
eval "nvidia-settings -a GPUFanControlState=0" |
View stat.hs
This file contains 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
-- Functions for statistics | |
import Data.List | |
-- Averages | |
average p = (sum p) / (fromIntegral $ length p) -- arithmetic mean | |
geomean p = (product p) ** (1.0 / (fromIntegral $ length p)) -- geometric mean | |
harmean p = (fromIntegral $ length p) / (sum $ map (\x -> 1.0 / x) p) -- harmonic mean | |
rms p = sqrt $ average $ map (\x -> x * x) p -- quadratic mean (RMS) |
View timezone.c
This file contains 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
#include <time.h> | |
signed long getTZ () | |
{ | |
struct tm* timeStruct; | |
time_t timeValBase = 86400; /* I know an implementation in which time_t is unsigned */ | |
time_t timeVal; | |
timeStruct = gmtime(&timeValBase); /* parse as the universal time */ | |
timeVal = mktime(tp); /* intentionally treat as the local time in order to find the time zone */ |
View scala.xml
This file contains 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
<NotepadPlus> | |
<UserLang name="Scala" ext="scala" udlVersion="2.0"> | |
<Settings> | |
<Global caseIgnored="no" allowFoldOfComments="no" forceLineCommentsAtBOL="no" foldCompact="no" /> | |
<Prefix Keywords1="no" Keywords2="no" Keywords3="yes" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> | |
</Settings> | |
<KeywordLists> | |
<Keywords name="Comments" id="0">00// 01 02 03/* 04*/</Keywords> | |
<Keywords name="Numbers, additional" id="1"></Keywords> | |
<Keywords name="Numbers, prefixes" id="2">0x</Keywords> |
View rational.hpp
This file contains 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
#pragma once | |
#include <stdexcept> | |
// Calculate GCD (for reduction) | |
template<typename T> T gcd(T x, T y) { | |
// Euclidean algorithm | |
T val1 = (x < y) ? y : x, val2 = (x < y) ? x : y; | |
T* m = &val1; T* n = &val2; T* tmpptr = nullptr; | |
while (true) { |
View paco-glib-issue.patch
This file contains 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
diff -ru paco-2.0.9/gpaco/gconfig.h paco-2.0.9-newglib/gpaco/gconfig.h | |
--- paco-2.0.9/gpaco/gconfig.h 2010-06-26 04:51:00.000000000 +0900 | |
+++ paco-2.0.9-newglib/gpaco/gconfig.h 2013-01-08 13:03:12.497896388 +0900 | |
@@ -11,7 +11,7 @@ | |
#include "paco/baseconfig.h" | |
#include <glibmm/ustring.h> | |
-#include <glib/gkeyfile.h> | |
+#include <glib.h> | |
#include <vector> |
NewerOlder