Skip to content

Instantly share code, notes, and snippets.

View kaneshin's full-sized avatar
🏠
Working from home

Shintaro Kaneko kaneshin

🏠
Working from home
View GitHub Profile
@kaneshin
kaneshin / gist:1342018
Created November 5, 2011 21:03
jquery onload
$.event.add(window, "load", function() {
$("#" + act).animate({top: '48%', }, 2000 );
});
var Header = {
addFade: function( selector ) {
var cls = "fake-hover";
$('<span class="' + cls + '"></span>')
.css("display", "none")
.prependTo( $(selector) );
$(selector + " a").bind( "mouseenter", function() {
$(selector + " ." + cls).fadeIn( "slow" )
});
$(selector + " a").bind( "mouseleave" , function() {
xnorm = ZERO ;
for (i = 0; i < n5; i++) if ( xnorm < fabs (x [i]) ) xnorm = fabs (x [i]) ;
for (; i < n; i += 5)
{
if ( xnorm < fabs (x [i] ) ) xnorm = fabs (x [i] ) ;
if ( xnorm < fabs (x [i+1]) ) xnorm = fabs (x [i+1]) ;
if ( xnorm < fabs (x [i+2]) ) xnorm = fabs (x [i+2]) ;
if ( xnorm < fabs (x [i+3]) ) xnorm = fabs (x [i+3]) ;
if ( xnorm < fabs (x [i+4]) ) xnorm = fabs (x [i+4]) ;
}
@kaneshin
kaneshin / vecmat.c
Created November 22, 2011 09:16
dynamic definition of vector and matrix.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void
print_vec(double *v, int n) {
int i;
for (i = 0; i < n; i++) {
printf("vec_%d = %.4f\n", i + 1, v[i]);
}
@kaneshin
kaneshin / gist:1397100
Created November 27, 2011 06:39
bash array
SDFILE=("3PK" "BRYBND" "BARD" "WATSON" "ALLINIT" "ALLINITC" "ALLINITU")
for (( i = 0; i < ${#SDFILE[@]}; i++ ))
do
echo ${SDFILE[$i]}
echo -e "\n${SDFILE[$i]}\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $LOG
date >> $LOG
sdcg_descent ${SDFILE[$i]} 2>&1 >> $LOG
done
var foo = {
bar: 10,
baz: function(num, callback) {
callback(num * num);
},
qux: function(num, callback) {
var self = this;
this.baz(num, function(res) {
callback(res + self.bar);
});
#include <stdio.h>
int
integrate
(
int a,
int b,
double (*f)(double *, int),
int n
)
#include <stdio.h>
double
integrate(
double a,
double b,
double (*f)(double)
){
int i, size = 1000;
double area = 0., d = (b - a) / size;
#include <stdio.h>
#define return printf("Hello world");return
int
main() {
return 0;
}
let url = 'http://www.tepco.co.jp'
let indexj = '/cc/press/index-j.html'
let res = webapi#http#get(url.indexj)
if res.header[0] != 'HTTP/1.1 200 OK'
echo 'Oops! Something wrong.'
endif
let data = iconv(res.content, 'utf-8', &encoding)
for list in split(data, '\n')
if list =~ '<dd><a href="'
if matchstr(list, '<dd><a href=".\+">\zs.\+\ze<\/a><\/dd>')