Skip to content

Instantly share code, notes, and snippets.

@rphlmr
rphlmr / helpers.ts
Last active May 21, 2024 17:30
Drizzle ORM, deep sub queries
/* -------------------------------------------------------------------------- */
/* More here; */
/* -------------------------------------------------------------------------- */
//gist.github.com/rphlmr/0d1722a794ed5a16da0fdf6652902b15
https: export function distinctOn<Column extends AnyColumn>(column: Column) {
return sql<Column["_"]["data"]>`distinct on (${column}) ${column}`;
}
export function jsonBuildObject<T extends SelectedFields>(shape: T) {
@WebReflection
WebReflection / esx.md
Last active May 26, 2024 02:33
Proposal: an ESX for JS implementation
@RealyUniqueName
RealyUniqueName / Json.hx
Last active February 10, 2022 15:45
Sample PHP externs for Haxe
//You can use any package name here.
//It's not required to match the namespace of php file.
package;
import php.NativeStructArray;
typedef EncodingOptions = {
?prettyPrint:Bool,
?enableJsonExprFinder:Bool,
}
@nadako
nadako / 1 Main.hx
Last active October 16, 2021 04:38
ocaml-like `with` for Haxe
using WithMacro;
typedef Player = {
final name:String;
final level:Int;
}
class Main {
static function main() {
var player = {name: "Dan", level: 15};
class Container<Action, State> {
var state:tink.state.State<State>;
var reducer:State->Action->State;
public function new(initial, reducer) {
this.state = new State(initial);
this.reducer = reducer;
}
@tibdex
tibdex / absolute-to-relative.js
Created December 9, 2016 19:22
jscodeshift codemod to change imports of internal modules using absolute path to relative path
/**
* This codemod expects 2 CLI arguments:
* - packageDir: the path of the directory containing the package.json. It's used to detect whether a path points
* to a dependency or an internal module.
* - rootDirs: root directory paths separated by a comma if you have more than one root.
* Let's say that you have two files:
* - src/component.js
* - src/index.js containing the import "import Component from 'component.js';"
* To have the transformation successfully working you need to call jscodeshift with the "--rootDirs ./src" argument.
*/
@joecampo
joecampo / install_pdo_sqlsrv.sh
Last active May 25, 2023 00:14
Install Official MSSQL driver for Unbuntu 14.04 - pdo_sqlsrv
#!/bin/bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo -i export CPPFLAGS="-DSIZEOF_LONG_INT=8"
sudo apt-get -y install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
cd ~
echo "Configuring the unixODBC 2.3.1 Driver Manager"
@miklund
miklund / 2016-06-19 creating-a-webassembly-binary-and-running-it-in-a-browser
Last active June 14, 2022 21:12
2016-06-19 Creating a WebAssembly binary and running it in a browser
# Title: Creating a WebAssembly binary and running it in a browser
# Author: Mikael Lundin
# Date: 2016-06-19