Skip to content

Instantly share code, notes, and snippets.

View ovcharik's full-sized avatar

Maksim Ovcharik ovcharik

  • Saint Petersburg, Russia
View GitHub Profile
@Orabig
Orabig / app.component.ts
Last active November 3, 2024 19:14
Centrifugo Client Service for Angular 2 #Centrifugo #Angular2 #service
// Register your service as usual. I suggest adding it to [providers] in the module definition
// Then...
...
var user = ...;
var info = ...; // Optional
var timestamp = Date.now() / 1000 | 0;
var token = <Get the token from your ws>;
this.centrifugeService.connect({
url: 'http://<centrifugoServer>:8000/connection',
@hediet
hediet / main.md
Last active November 13, 2024 17:23
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
@hackprime
hackprime / number.in.words.js
Last active May 31, 2023 07:16
Convert number from digits to words in Russian
var TRIPLET_NAMES = [
null,
['тысяча', 'тысячи', 'тысяч'],
['миллион', 'миллиона', 'миллионов'],
['миллиард', 'миллиарда', 'миллиардов'],
['триллион', 'триллиона', 'триллионов'],
['квадриллион', 'квадриллиона', 'квадриллионов'],
],
ZERO_NAME = 'нуль',
ONE_THOUSANT_NAME = 'одна',
@hubertursua
hubertursua / node-forever-upstart.conf
Last active December 7, 2018 17:53
NodeJS, Forever, and Upstart (Ubuntu)
#!upstart
start on filesystem and started networking
stop on shutdown
expect fork
setuid ubuntu
env HOME="/home/ubuntu"
@XProger
XProger / blend.cpp
Created October 14, 2014 20:33
Fast integer alpha blending
uint32 blend(uint32 color1, uint32 color2, uint8 alpha) {
uint32 rb = color1 & 0xff00ff;
uint32 g = color1 & 0x00ff00;
rb += ((color2 & 0xff00ff) - rb) * alpha >> 8;
g += ((color2 & 0x00ff00) - g) * alpha >> 8;
return (rb & 0xff00ff) | (g & 0xff00);
}
@jo
jo / js-crypto-libraries.md
Last active November 2, 2024 04:38
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

List some crypto libraries for JavaScript out there. Might be a bit out dated. Scroll to the bottom.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@cballou
cballou / new-csshook-template.js
Created November 3, 2012 11:19
Creating jQuery CSS3 Vendor Prefix Mixins with $.cssHooks
(function($) {
if ( !$.cssHooks ) {
throw("jQuery 1.4.3+ is needed for this plugin to work");
return;
}
function styleSupport( prop ) {
var vendorProp, supportedProp,
capProp = prop.charAt(0).toUpperCase() + prop.slice(1),
prefixes = [ "Moz", "Webkit", "O", "ms" ],
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@geek0x23
geek0x23 / customer.js
Created November 9, 2011 01:41
A mongoose model that takes advantage of the handy invalidate method to run multiple validations
var mongoose = require('./db-connect'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
uuid = require('node-uuid'),
Validator = require('validator').Validator,
val = new Validator(),
bcrypt = require('bcrypt');
Validator.prototype.error = function(msg) { return false; };