Skip to content

Instantly share code, notes, and snippets.

View JCMais's full-sized avatar
🚀
Being Happy

Jonathan Cardoso JCMais

🚀
Being Happy
View GitHub Profile
@gubatron
gubatron / compiling_building_c_cpp_notes.md
Last active April 18, 2024 07:58
Things to remember when compiling and linking C/C++ programs

Things to remember when compiling/linking C/C++ software

by Angel Leon. March 17, 2015;

Last update on December 14, 2023

Updated on February 27, 2023

Updated August 29, 2019.

@knownasilya
knownasilya / index.html
Last active November 6, 2023 18:45 — forked from Hagith/drawing-tools.html
Google Maps Advanced Drawing
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Drawing Tools</title>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false&libraries=drawing"></script>
<style type="text/css">
#map, html, body {
CREATE OR REPLACE FUNCTION generate_object_id() RETURNS varchar AS $$
DECLARE
time_component bigint;
machine_id int := FLOOR(random() * 16777215);
process_id int;
seq_id bigint := FLOOR(random() * 16777215);
result varchar:= '';
BEGIN
SELECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp())) INTO time_component;
SELECT pg_backend_pid() INTO process_id;
@teeberg
teeberg / circleci.py
Created January 8, 2016 23:19
CircleCI Command Line Helper
#!/usr/bin/env python
import os
import pprint
import subprocess
import sys
from optparse import make_option
from urllib import quote_plus
from urlparse import urljoin
import dateutil.parser
@williewillus
williewillus / primer.md
Last active December 20, 2020 08:13
1.8.9 to 1.9 quick primer
@ramsey
ramsey / uuid.php
Created October 26, 2016 23:37
Creating an ordered time UUID alongside a timestamp-first COMB UUID.
<?php
// composer require ramsey/uuid moontoast/math
require_once 'vendor/autoload.php';
use Ramsey\Uuid\Codec\OrderedTimeCodec;
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
use Ramsey\Uuid\Generator\CombGenerator;
use Ramsey\Uuid\UuidFactory;
@armand1m
armand1m / Dockerfile
Last active March 10, 2024 14:54
Yarn cache compatible Dockerfile
FROM alpine
RUN apk add --update --no-cache nodejs
RUN npm i -g yarn
ADD package.json yarn.lock /tmp/
ADD .yarn-cache.tgz /
RUN cd /tmp && yarn
RUN mkdir -p /service && cd /service && ln -s /tmp/node_modules
@joepie91
joepie91 / random.md
Last active May 19, 2024 18:16
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@redrabbit
redrabbit / absinthe_ecto_resolution_schema.ex
Last active December 1, 2023 14:29
Absinthe.Ecto.Resolution.Schema
defmodule Absinthe.Ecto.Resolution.Schema do
@moduledoc """
This module provides helper functions to resolve a GraphQL query into `Ecto.Query`.
"""
import Absinthe.Resolution.Helpers
import Ecto.Query
alias Absinthe.Resolution
alias Absinthe.Blueprint.Document.Field
@nodkz
nodkz / relayStore.js
Last active June 29, 2017 01:30
relayStore with `reset` and simplified `mutate` methods
let relayStore;
function relayCreateStore() {
const env = new Relay.Environment();
env.injectNetworkLayer(new Relay.DefaultNetworkLayer('/graphql'));
if (__DEV__) {
RelayNetworkDebug.init(env);
}
env.reset = () => relayCreateStore();
env.mutate = ({
query,