Skip to content

Instantly share code, notes, and snippets.

View rmdwirizki's full-sized avatar
🏹
Messing up the code

Rizki Lazuardi rmdwirizki

🏹
Messing up the code
View GitHub Profile
const fetch = require('node-fetch')
const crypto = require('crypto')
const path = require('path')
const fs = require('fs');
const _ = require('lodash');
exports.sourceNodes = async ({ actions }) => {
const { createNode } = actions
const createProduct = (var1, var2) => {
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active February 13, 2024 14:30
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.
@numberoverzero
numberoverzero / async_value.py
Created July 6, 2015 02:50
Variable that can be `await`ed on to reach a certain value, without blocking an event loop
import asyncio
missing = object()
class Value:
'''
Simple class that enables `await value.wait_for(foo)` to wait until the
variable is set to the expected value, without blocking the event loop.
Loosely modeled after asyncio.Event and asyncio.Condition
@julianlam
julianlam / expose-directory-on-host-to-lxc-container.md
Last active April 7, 2024 04:01
Exposing a directory on the host machine to an LXC container #blog

Exposing a directory on the host machine to an LXC container

  1. Log into the container and create an empty directory, this will be the mount point
  2. Log out and stop the container.
  3. Open to your container's config file
    • For regular LXC containers: /var/lib/lxc/mycontainer/config
    • For unprivileged LXC containers: $HOME/.local/share/lxc/mycontainer/config
  4. Add a new line above the lxc.mount directive, that follows the format below. Substitute proper paths as necessary:
    • lxc.mount.entry = /path/to/folder/on/host /path/to/mount/point none bind 0 0
  • Both of these paths are relative to the host machine.
@bgrayburn
bgrayburn / wordWrap
Last active May 30, 2022 15:37
A javascript function to word wrap given a long string and a max line length
var wordwrap = function(long_string, max_char){
var sum_length_of_words = function(word_array){
var out = 0;
if (word_array.length!=0){
for (var i=0; i<word_array.length; i++){
var word = word_array[i];
out = out + word.length;
}
};
@mul14
mul14 / 00_etc-hosts.md
Last active April 2, 2024 06:39
/etc/hosts for Vimeo, Reddit, Imgur, GitHub, DigitalOcean, dll

Unblock Steam, Vimeo, Reddit, Imgur, GitHub, DigitalOcean, NPM, PayPal, dll

Saya support Internet Positif untuk memblokir porn, situs judi, dan hal-hal ilegal lainnya. Tapi pemerintah dan ISP sangat konyol karena tidak mengizinkan akses ke Vimeo, Reddit, Imgur, Netflix--yang mana bukanlah situs dengan konten utama ilegal.

Linux / BSD / macOS

Tambahkan list di bawah ke /etc/hosts.

Windows

@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@jasdeepkhalsa
jasdeepkhalsa / longPolling.js
Last active April 17, 2024 10:59
Simple Long Polling Example with JavaScript and jQuery by Tian Davis (@tiandavis) from Techoctave.com (http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery)
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast)
(function poll(){
$.ajax({ url: "server", success: function(data){
//Update your dashboard gauge
salesGauge.setValue(data.value);
}, dataType: "json", complete: poll, timeout: 30000 });
})();