Skip to content

Instantly share code, notes, and snippets.

View tamascsaba's full-sized avatar

Csaba Tamás tamascsaba

View GitHub Profile
@piroor
piroor / aes-gcm-encryption.js
Last active August 16, 2022 08:02
Example of AES-GCM encryptor with passphrase, based on Web Crypto API
async function getKey(passphrase, salt = null) {
passphrase = (new TextEncoder()).encode(passphrase);
let digest = await crypto.subtle.digest({ name: 'SHA-256' }, passphrase);
let keyMaterial = await crypto.subtle.importKey(
'raw',
digest,
{ name: 'PBKDF2' },
false,
['deriveKey']
);
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active March 22, 2025 07:22
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
/**
* Jest Conversion script
* This script isn't the cleanest, and uses two different methods for performing global replaces... but it gets the job done.
* We switched from using the `replace` method to the `advancedReplace` about 70% of the way through, and couldn't go and retrofit
* `advancedReplace` everywhere with 100% confidence. However, should you use this script as a base for your own migration,
* I would definitely suggest using `advancedReplace`, which uses the node-replace library.
*/
import {sync as globSync} from 'glob'
import {execSync} from 'child_process'
import fs from 'fs'
@andras-tim
andras-tim / fun.zsh
Last active September 21, 2021 11:53
I love pipes, redirects and named fds... in ZSH!
#!/usr/bin/zsh
set -e
# TAB indented file!
### PREPARATION ###
# mkdir test
# cd test
# wget -q https://gist.github.com/andras-tim/f8aebf9243cecf3719d27d020a718ef8/raw/fun.zsh -O - | zsh
@nagyv
nagyv / README.md
Last active September 20, 2016 13:28
Git image diff

What it this for?

Have you ever wandered how to follow changes in images using git? This is a solution for the problem.

How to install

  1. Copy git-imgdiff.sh somewhere under your $PATH. Probably $HOME/bin.
  2. Create the $HOME/.gitattributes file with the following content ~/.gitattributes
@btroncone
btroncone / rxjs_operators_by_example.md
Last active March 30, 2025 21:26
RxJS 5 Operators By Example
@btroncone
btroncone / ngrxintro.md
Last active March 5, 2025 20:40
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@domenic
domenic / 0-usage.js
Last active August 21, 2023 09:02
Import module function (assuming <script type="module"> is implemented)
// Dynamic module loading using runtime-composed strings, decisions, etc.
for (const m of ["cool", "awesome", "fun", "whee"]) {
if (Math.random() > 0.5) {
importModule(`/js/${m}.js`).then(
module => console.log("Module instance object for " + m, module),
e => console.error(e)
);
}
}
@clemcke
clemcke / persos.service.spec.ts
Last active February 8, 2016 09:05
Sample spec that uses appInjector() and a service
import {it, describe, expect, inject, beforeEach, beforeEachProviders} from 'angular2/testing'
import {PersonService, PERSON_SERVICE_PROVIDERS, personServiceLoadedPromise} from './person.service'
// Contents of person.service.ts
//@Injectable()
//export class PersonService {
// constructor(private _http: Http) { }
//
// init(): Promise<boolean>{
// return this._http.get('myurl').toPromise();
// }