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
#! /usr/bin/env python | |
""" | |
Solve linear system using LU decomposition and Gaussian elimination | |
""" | |
import numpy as np | |
from scipy.linalg import lu, inv | |
def gausselim(A,B): |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Attribution: Hijacked from tracservice.py by Florent Xicluna <laxyf@yahoo.fr> | |
# http://trac-hacks.org/wiki/WindowsServiceScript | |
# | |
# To use this class, users must do the following: | |
# 1. Download and install the PyWin32all package | |
# (http://starship.python.net/crew/mhammond/win32/) | |
# 2. Edit the constants section with the proper information. |
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
--- C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.txt | |
+++ C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat | |
@@ -16,23 +16,23 @@ | |
goto :eof | |
:amd64 | |
-if not exist "%~dp0bin\amd64\vcvarsamd64.bat" goto missing | |
-call "%~dp0bin\amd64\vcvarsamd64.bat" | |
+if not exist "%~dp0bin\vcvars64.bat" goto missing | |
+call "%~dp0bin\vcvars64.bat" |
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
from pygments.lexers import MatlabLexer | |
from pygments.formatter import Formatter | |
from pygments.token import STANDARD_TYPES | |
from pygments import highlight | |
class JSONFormatter(Formatter): | |
def format(self, tokensource, outfile): | |
tokensource = [{STANDARD_TYPES[k]: v} for k, v in tokensource] | |
json.dump(tokensource, outfile) |
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
# -*- coding: utf-8 -*- | |
""" | |
Starts the help server so that Sphinx search works even in Google Chrome. | |
""" | |
import SimpleHTTPServer | |
import SocketServer | |
from threading import Thread | |
from Queue import Queue |
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 [angles,projection] = solarPosition(datetime,latitude,longitude,time_zone,rotation,dst) | |
%SOLARPOSITION Calculate solar position using most basic algorithm | |
% This is the most basic algorithm. It is documented in Seinfeld & | |
% Pandis, Duffie & Beckman and Wikipedia. | |
% | |
% [ANGLES,PROJECTION] = SOLARPOSITION(DATE,TIME,LATITUDE,LONGITUDE,TIME_ZONE) | |
% returns ZENITH & AZIMUTH for all DATE & TIME pairs at LATITUDE, LONGITUDE. | |
% ANGLES = [ZENITH,AZIMUTH] and PROJECTION = [PHI_X, PHI_Y] | |
% PHI_X is projection on x-z plane & PHI_Y is projection on y-z plane. | |
% DATETIME can be string, vector [YEAR, MONTH, DAY, HOURS, MINUTES, SECONDS], |
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
#! /usr/bin/env python | |
import numpy as np | |
from datetime import datetime, time, timedelta | |
import pytz | |
class Timeseries(object): | |
def __init__(self, x, t): | |
self.x = np.array(x) | |
self.t = np.array(t,dtype='datetime64[s]') |
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
#! /usr/bin/env python | |
""" | |
Python metaclasses | |
================== | |
A metaclass is a class factory; metaclasses serve two purposes: | |
1. replace ``type`` as the base class metatype for classes with the | |
``__metaclass__`` attribute |
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
static KeyPair OpenSSH2JavaKeyPairDemo(InputStream pub, InputStream pvt) | |
throws IOException, GeneralSecurityException | |
{ | |
KeyFactory f = KeyFactory.getInstance("RSA"); | |
RSAPublicKeySpec pubspec = decodeRSAPublicSSH(readAllBase64Bytes(pub)); | |
RSAPrivateCrtKeySpec pvtspec = decodeRSAPrivatePKCS1(readAllBase64Bytes(pvt)); | |
return new KeyPair(f.generatePublic(pubspec), f.generatePrivate(pvtspec)); | |
} |
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
%% initialize workspace | |
close('all'),clear('all'),clc | |
rmdir('keys','s') % delete old keys | |
%% test encryption | |
PANGRAM = 'The quick brown fox jumped over the lazy dog.'; | |
EncryptionUtil.testJschSECSH(PANGRAM) % run test | |
%% make SSH keys in workspace | |
keyFactory = java.security.KeyFactory.getInstance('RSA'); % make a key factory | |
% read public OpenSSH key | |
[keyln, totlines] = EncryptionUtil.readJschKeyFile('keys/publicJschSECSH.key',7); |