Skip to content

Instantly share code, notes, and snippets.

@Centrinia
Centrinia / Ajax Import
Created July 29, 2014 05:10
Blog Reply
'use strict';
$(document).ready(function() {
var openedReplyUrl = null;
var openedReplyComment = null;
$('.comment').each(function (index, commentElement) {
$(commentElement).find('.reply').click(function (e) {
var replyUrl = $(commentElement).attr('reply-url');
if(openedReplyUrl == replyUrl) {
return;
#!/usr/bin/python3
#import png
import itertools
import time
import numpy as np
import math
import random
import os
@Centrinia
Centrinia / bf.hs
Last active August 30, 2017 05:58
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
module Main where {
import Data.Maybe (catMaybes);
import Data.Function (on);
import Data.List (group,intersperse,sort,sortBy,groupBy);
import qualified Control.Monad.State as S;
--import Control.Monad.Writer;
import Text.ParserCombinators.ReadP;
#!/usr/bin/python3
#import png
import itertools
import time
import numpy as np
import math
import random
import os
#include <stdlib.h>
#include <stdio.h>
typedef int bool;
#define true 1
#define false 0
#define SWAP(a,b) { (a) ^= (b); (b) ^= (a); (a) ^= (b); }
@Centrinia
Centrinia / sudoku.py
Created October 9, 2015 14:10
Sudoku
#!/usr/bin/python3
import sys
import itertools
import time
N = 9
S = 3
def process(f):
@Centrinia
Centrinia / bitset.h
Created November 3, 2015 01:03
Sieve of Eratosthenes With Wheel
/* bitset.h */
template <typename T>
inline constexpr T ceildiv(const T a, const T b) {
return (a + b - 1) / b;
}
/* Rotate the bits of x to the right by I bits. */
template <typename T>
inline T rotate_right(const T & x, const int & I)
@Centrinia
Centrinia / box_fragment.glsl
Created January 12, 2016 18:41
Frustum Viewer
#version 430
struct atlas_entry {
ivec2 pos;
ivec2 size;
};
uniform Atlas {
atlas_entry entries[1024];
} uAtlas;
// Gaussian filter of image
__kernel void gaussian_filter(__read_only image2d_t srcImg,
__write_only image2d_t dstImg,
sampler_t sampler,
int width, int height)
{
// Gaussian Kernel is:
// 1 2 1
@Centrinia
Centrinia / log
Last active January 15, 2016 16:49
exc@lambda ~/src/examples/opencl/prefix_sum $ optirun python3 prefix_sum.py
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 26 27 28 29 30 31]
(16,) None
<pyopencl.cffi_cl.CommandQueue object at 0x7f378fefcac8> (16,) None <pyopencl.cffi_cl.Buffer object at 0x7f3787cce470> <pyopencl.cffi_cl.Buffer object at 0x7f3787cd8d68> 0 1
Adding ap[54668944] and ap[109337888] (start, stride: 54668944, 54668944), (size: 16,0)
Adding ap[164006832] and ap[218675776] (start, stride: 54668944, 54668944), (size: 16,0)
Adding ap[273344720] and ap[328013664] (start, stride: 54668944, 54668944), (size: 16,0)
Adding ap[382682608] and ap[437351552] (start, stride: 54668944, 54668944), (size: 16,0)
Adding ap[492020496] and ap[546689440] (start, stride: 54668944, 54668944), (size: 16,0)