Skip to content

Instantly share code, notes, and snippets.

@pif
pif / gist:c59a9cae30983b6e7bc5
Created March 25, 2015 21:04
Move all Dropbox Camera Uploads files to separate folders. New folder format is YYYY_MM_DD. E.g.: 2015_01_22
~/D/Camera Uploads ❯❯❯ IFS=$'\n'; for f in $(ls | cat)
do
folder=$(echo $f | sed "s/\(\) \([0-9][0-9]\.[0-9][0-9]\.[0-9][0-9].*\)/\1/g" | sed "s/-/_/g")
echo "Moving $f to $folder"
mv $f ~/BACKUP/$folder
done
/* Begin Images */
p img {
padding: 0;
max-width: 100%;
}
/* Using 'class="alignright"' on an image will (who would've
thought?!) align the image to the right. And using 'class="centered',
will of course center the image. This is much better than using
align="center", being much more futureproof (and valid) */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ostap.chyselni;
/**
*
* @author Ostap.Andrusiv
*/
@pif
pif / Chyselni3.java
Created November 9, 2010 22:47
habe to impreve df
/*
При фиксированном значении k биномиальные коэффициенты могут быть вычислены по рекуррентной формуле
(n k) = n/(n-k) * (n-1 k)
с начальным значением (k k) = 1. Для вычисления значения этот метод требует O(1) памяти и O(n) времени.
*/
package ua.org.pifostap;
import java.io.*;
import java.util.Scanner;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import processing.core.PApplet;
import processing.core.PVector;
/**
*
* @author Ostap
@pif
pif / gist:802712
Created January 30, 2011 09:27
mount ISO images under Linux
Procedure to mount ISO images under Linux
1) You must login as a root user, if not root user then switch to root user using following command:
$ su -
2) Create the directory i.e. mount point:
# mkdir -p /mnt/disk
3) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk
@pif
pif / gist:825660
Created February 14, 2011 09:30
chastokil
#include <iostream>
#include <string>
#include <fstream>
//#include <stdlib.h>
using namespace std;
int* generateHeightArray(int h, int mesLen) {
int* idxs = new int[mesLen];
@pif
pif / gist:892391
Created March 29, 2011 13:49
MAP method
static public final float map(float value,
float istart, float istop,
float ostart, float ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}
@pif
pif / GCD.cpp
Created April 3, 2011 21:18
gcd: while/recursion
#include <iostream>
using namespace std;
int gcd(int a,int b) {
if (!b) {
return a;
}
cout<<a<<"="<<b<<"*"<<a/b<<"+"<<a%b<<endl;
return gcd(b, a%b);
@pif
pif / gist:912262
Created April 10, 2011 11:19
MODPOW
http://homepages.gold.ac.uk/rachel/Mods.doc
To compute x^n mod p
Initialise y=1; u=x mod p;
Repeat
If n is odd then y:=(y*u) mod p;
n:=n div 2;
u:=(u*u) mod p;
Until n==0;