Skip to content

Instantly share code, notes, and snippets.

View ZAYEC77's full-sized avatar
:octocat:
piu-piu

Dmytro Karpovych ZAYEC77

:octocat:
piu-piu
View GitHub Profile
@ZAYEC77
ZAYEC77 / queue.js
Last active September 10, 2015 14:14
Queue JS
function Queue() {
var self = this;
self.queue = [];
self.push = function (fn, context, params) {
params = params || [];
context = context || this;
self.queue.push({fn: fn, params: params, context: context});
return self;
};
@ZAYEC77
ZAYEC77 / fabricJS history
Created September 12, 2015 10:30
History implementation for fabricJS
function (canvas, container) {
var history = {state: [], lock: true, mods: 0};
app.history = history;
canvas.on('history.lock', function () {
history.lock = true;
});
canvas.on('history.unlock', function () {
history.lock = false;
@ZAYEC77
ZAYEC77 / parallel.js
Last active September 15, 2015 20:00
Parallel JS
function Parallel() {
var self = this;
self.finished = 0;
self.length = 0;
self.list = [];
self.add = function (fn, context, params) {
params = params || [];
context = context || this;
self.list.push({fn: fn, params: params, context: context});
db-create:
mysql -u user -p -e 'CREATE SCHEMA `db-name` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
db-update:
php yii modules-migrate
message:
php yii message src/messages/config.php
vendors-update:
composer update
vendors-install:
composer install -o
sudo mount /dev/sdaX /mnt # Make "X" the partition that has Ubuntu installed (i.e. /dev/sda2).
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt/$i"; done
sudo chroot /mnt
update-grub
if no errors skip this
grub-install /dev/sdX (x is the hard drive that has linux installed (i.e. /dev/sda)
update-grub Reboot the system
@ZAYEC77
ZAYEC77 / grayscale.css
Created January 8, 2016 23:40
transition image grayscale on css3
.grayscale {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray; /* IE 6-9 */
-webkit-transition: all 1s;
-moz-transition: all 1s;
/** Usage
<span id="permutable4"
onmouseenter="permute('permutable4')"
onmouseleave="unpermute('About','permutable4')"
onclick="unpermute('About','permutable4')">
About
</span>
**/
var ewig = "";
/**
* Gulpfile only for postcss usage
*
* Good for WP
*
* Direcotry structure:
* -/
* |-/post-css/
* |- style.css
* |-/css/
@ZAYEC77
ZAYEC77 / qsort.cpp
Created April 15, 2016 21:19
qsort on C++
void quickSort(int arr[], int left, int right) {
int i = left, j = right;
int tmp;
int pivot = arr[(left + right) / 2];
/* partition */
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
@ZAYEC77
ZAYEC77 / line_eratosthenes.cpp
Created April 15, 2016 21:22
Lineer eratosthenes
const int N = 10000000;
int lp[N+1];
vector<int> pr;
for (int i=2; i<=N; ++i) {
if (lp[i] == 0) {
lp[i] = i;
pr.push_back (i);
}
for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)