Skip to content

Instantly share code, notes, and snippets.

View mustafat0k's full-sized avatar
🚀
Go

Mustafa mustafat0k

🚀
Go
View GitHub Profile
@mustafat0k
mustafat0k / .js
Created March 6, 2021 14:05
pull all images from xml
'use strict';
const fs = require('fs');
const xml2js = require('xml2js');
const request = require('request')
const parser = xml2js.Parser();
const { v4: uuidv4 } = require('uuid');
const download = (url, path, callback) => {
request.head(url, (err, res, body) => {
//Here's a lock free stack I made (ripped off from Herb) using c++20 atomic shared_ptr, maybe it gives you some ideas:
template <typename T>
class LockFreeStack {
struct Node {
T t;
shared_ptr<Node> next;
};
atomic<shared_ptr<Node>> head;
/*
This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
http://creativecommons.org/licenses/publicdomain. Send questions,
comments, complaints, performance data, etc to [email protected]
* Version 2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee)
Note: There may be an updated version of this malloc obtainable at
ftp://gee.cs.oswego.edu/pub/misc/malloc.c
//Conway's Game of Life
// The universe of Conway's Game of Life is an infinite, two-dimensional orthogonal grid of cells, each of which is in one of two possible states: alive or dead. Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent (upper left, top, upper right, right, lower right, bottom, bottom left, left). At each step in time, the following transitions occur:
// Any live cell with fewer than two live neighbors dies due to under-population.
// Any live cell with two or three live neighbors lives on to the next generation (no change).
// Any live cell with more than three live neighbors dies due to overpopulation.
// Any dead cell with exactly three live neighbors becomes a live cell by reproduction.
// The initial pattern constitutes the seed if the system (starts it off). The first generation is created by applying the above rules simultaneously to every cell in the seed; births and deaths occur simultaneously, and the discrete
#include <stdio.h>
#include <signal.h>
#include <syslog.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@mustafat0k
mustafat0k / daemon.cpp
Created October 22, 2019 18:21 — forked from alexdlaird/daemon.cpp
Useful as a starting point for a C++ based Linux daemon application.
#include <dirent.h>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <sys/stat.h>
#include <syslog.h>
@mustafat0k
mustafat0k / keyhook.cpp
Created March 16, 2019 17:00
Capslock keyboard hook
#include <windows.h>
void GenerateKey(int vk, BOOL bExtended);
int main()
{
GenerateKey('A', FALSE);
GenerateKey(VK_CAPITAL, TRUE);
GenerateKey('A', FALSE);
@mustafat0k
mustafat0k / firewall.cpp
Created March 9, 2019 15:47
Exercising the Firewall using C++
/*
Copyright (c) Microsoft Corporation
The following code example exercises the Windows Firewall profile; displays the current profile, turns off the firewall,
turns on the firewall, and adds an application.
*/
#include <windows.h>
#include <crtdbg.h>
#include <netfw.h>
@mustafat0k
mustafat0k / HTML5StorageMultidimensional.js
Created March 4, 2018 16:17 — forked from klederson/HTML5StorageMultidimensional.js
Adding Multidimensional Support for javascript / html5 sessionStorage , localStorage or just Storage object
/**
*
* MOVED TO: https://github.com/iFind/html5MultidimensionalStorage
*
* This methods extends the default HTML5 Storage object and add support
* to set and get multidimensional data
*
* @example Storage.setObj('users.albums.sexPistols',"blah");
* @example Storage.setObj('users.albums.sexPistols',{ sid : "My Way", nancy : "Bitch" });
* @example Storage.setObj('users.albums.sexPistols.sid',"Other songs");
@mustafat0k
mustafat0k / .php
Created February 8, 2018 02:59
Laravel file ovveride
<?php
public function get_dir(Request $request)
{
$root = base_path() . DIRECTORY_SEPARATOR;
// "C:\Users\fizikci\Desktop\dev\la1\"
$postDir = rawurldecode(base_path($request->get('dir')));