Skip to content

Instantly share code, notes, and snippets.

View FelikZ's full-sized avatar

Oleksii Shevchenko FelikZ

View GitHub Profile
@ryosuzuki
ryosuzuki / Node-ffi-array.md
Last active March 3, 2024 21:00
Node-ffi example: Passing and receiving array object between Node.js and C++ binding

Node-ffi with IntArray

Passing and receiving array object between Node.js and C++ binding

$ g++ -dynamiclib -o mylib.dylib main.cpp
$ node index.js
[matrix size: 100x100; n_nonzero: 4; density: 0.04%]

 (1, 1) 2.0000
@JamesMGreene
JamesMGreene / .editorconfig
Created November 16, 2015 12:04
Example EditorConfig file
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
@SteveRuben
SteveRuben / client.cpp
Created October 21, 2015 08:30
Multiple streaming in c++ using opencv; OpenCV video streaming over TCP/IP
/**
* OpenCV video streaming over TCP/IP
* Client: Receives video from server and display it
* by Steve Tuenkam
*/
#include "opencv2/opencv.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
@TooTallNate
TooTallNate / ref-buffer-type.js
Last active June 3, 2022 13:26
Fixed length "Buffer" type, for use in `ref-struct` type definitions.
var ref = require('ref');
module.exports = BufferType;
/**
* Fixed length "Buffer" type, for use in Struct type definitions.
*
* Optionally setting the `encoding` param will force to call
* `toString(encoding)` on the buffer returning a String instead.
*/
@eyecatchup
eyecatchup / hosts
Last active July 12, 2023 08:53
Disable Skype ads: 1.) Add hosts to your hosts file 2.) Flush DNS resolver cache (ipconfig /flushdns)
# Block Skype ads
127.0.0.1 *.msads.net
127.0.0.1 *.msecn.net
127.0.0.1 *.rad.msn.com
127.0.0.1 a.ads2.msads.net
127.0.0.1 ac3.msn.com
127.0.0.1 ad.doubleclick.net
127.0.0.1 adnexus.net
127.0.0.1 adnxs.com
127.0.0.1 ads1.msn.com
@ralphtheninja
ralphtheninja / JOBS.md
Last active April 28, 2021 00:38
Use JOBS=max to speed up native node modules

When npm installs native node modules it uses node-gyp to compile code. This is the seam node uses for targeting different operating systems, e.g. OS X, linux, Windows etc.

By default node-gyp compiles using one core and if you have more than one you probably want to utilize that power to speed up compile time. The way node-gyp handles this is by using the JOBS environment variable, which sets the jobs variable here. This piece of code then checks the value of jobs to determine how many cores to use.

Note that if the value of JOBS is max then all cores will be used. So lets try this on leveldown. First lets check that JOBS isn't set yet:

lms@ux301|01:34|~/src/leveldb-repos/leveldown (master) $ echo $JOBS

@GaryJones
GaryJones / RedirectsCept.php
Last active May 20, 2019 15:21
Codeception 301 Redirection Tests
<?php
$I = new RedirectsTester($scenario);
$I->wantTo('check 301 redirects are working');
// First, test /login/ page gets rewritten to https://
$I->seePermanentRedirectToHttpsFor('login/');
$I->seePermanentRedirectToHttpsFor('login/?redirect_to=foo');
@seyfer
seyfer / byzanz-record-window-gui
Created March 18, 2015 08:41
byzanz-record-window-gui
#!/bin/bash
# AUTHOR: (c) Rob W 2012, modified by MHC (http://askubuntu.com/users/81372/mhc)
# NAME: GIFRecord 0.1
# DESCRIPTION: A script to record GIF screencasts.
# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# DEPENDENCIES: byzanz,gdialog,notify-send (install via sudo add-apt-repository ppa:fossfreedom/byzanz; sudo apt-get update && sudo apt-get install byzanz gdialog notify-osd)
# Time and date
TIME=$(date +"%Y-%m-%d_%H%M%S")
//
// Copyright (c) 2014 Sean Farrell
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule