Skip to content

Instantly share code, notes, and snippets.

@igrigorik
igrigorik / index.html
Created June 8, 2013 22:36
XHR streaming example
<p>Hello
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', '/stream');
xhr.seenBytes = 0;
xhr.onreadystatechange = function() {
console.log("state change.. state: "+ xhr.readyState);
@rivo
rivo / serve.go
Created November 26, 2017 12:28
Graceful stop and restart for HTTP servers in Go
package main
import (
"context"
"fmt"
"net"
"net/http"
"os"
"os/exec"
"os/signal"
@Jomy10
Jomy10 / rust_in_swift.md
Last active May 2, 2024 05:59
Calling Rust library from Swift code (creating executable)

Calling a Rust library from Swift

This gist shows a quick overview of calling Rust in a Swift project, with Swift Package Manager configured.

Let's go ahead and create a folder containing all our sources:

mkdir swift-rs && cd $_
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
flat = {
'some.nested.keys': 'flat'
};
nested = {
some: {
nested: {
@MichalBryxi
MichalBryxi / controllers.application\.js
Created August 19, 2021 14:03
flat vs nested get
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
flat = {
'some.nested.keys': 'flat'
};
nested = {
some: {
nested: {
@sukima
sukima / simple-dom.js
Last active May 2, 2024 05:56
Very small DOM micro-lib using Proxy
/*******************************************/
/* Version 1.0.0 */
/* License MIT */
/* Copyright (C) 2022 Devin Weaver */
/* https://tritarget.org/cdn/simple-dom.js */
/*******************************************/
/**
* This micro lib is a compact and simple method to interact with the DOM. It
* facilitates the query mechanisms that querySelector and querySelectorAll use
@Durman
Durman / Progress bar for blender.md
Created January 21, 2022 17:30
Examples of creating a progress bar in Blender

Showing progress bar in Blender

Main problem of showing progress bar in Blender UI is that while a script is running the UI is frozen. So the simplest (?) solution is to break execution whenever the progress status should be updated. For this you can use either timers or modal operators. The last one can't be switched on during all time of Blender execution and has some starting costs.

import bpy
from functools import partial
@fatihacet
fatihacet / alert.js
Last active May 2, 2024 05:55
alert.js
window.IDE.appControllers.helloworld = function() {
time = new Date().toString().match(/(\d\d:\d\d:\d\d)/)[0];
view = new KDCustomHTMLView({
tagName: 'h2',
partial: 'HELLO WORLD APP LOADED at ' + time + ' !!!'
});
return view;
}
@fatihacet
fatihacet / just-number.js
Last active May 2, 2024 05:55
get only numbers in a string with regex
var k = '3dsaAdas2dAAASdasdasDŞ321ĞİÜEQWEWQ098"**?_Ü;SDA!22';
k.replace(/\D/g, '');
class FlipCounterView extends KDView
constructor : (options = {}, data = {}) ->
options.style ?= "dark"
options.from ?= 5000
options.to ?= 10000
options.interval ?= 1000
options.step ?= 1
options.autoStart ?= yes
options.direction = if options.from < options.to then "up" else "down"
options.digits ?= if options.direction is "up" then options.to.toString().length else options.from.toString().length