Skip to content

Instantly share code, notes, and snippets.

View serweb-labs's full-sized avatar

Luciano Rodríguez serweb-labs

View GitHub Profile
@adamstep
adamstep / mercure.py
Last active May 15, 2021 13:32
Using Mercure with Django for Server-sent events
# Helper functions for publishing events, generating JWT tokens, and generating the Hub URL.
def publish_event(event_type, topic, targets):
"""
Publishes an event to the Mercure Hub.
event_type: The type of the event, can be any string
topic: The topic the event will be sent to. Only subscribers who request this topic will get notified.
targets: The targets that are eligible to get the event.
"""
token = get_jwt_token([], targets)
anonymous
anonymous / index.html
Created September 29, 2017 21:15
JS Bin // source https://jsbin.com/hozehuqewi
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
body {
@Birdie0
Birdie0 / ifttt-webhooks-extended-guide.md
Last active September 16, 2024 21:37
How to use Discord Webhooks

⚠️ This gist is no longer updated! For maintained, improved and even more extended guide click here.


How to use Discord Webhook

It's a JSON

First, learn JSON. It's not programming language, not even close. Just follow syntax rules and you will be fine.

@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active September 17, 2024 08:31
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@spiralx
spiralx / promise.finally.polyfill.js
Created July 29, 2016 07:34
Polyfill to add a finally() method to the Promise object
Promise.prototype.finally = function (callback) {
return this.then(
value => this.constructor.resolve(callback()).then(() => value),
reason => this.constructor.resolve(callback()).then(() => { throw reason })
)
}
@maximbilan
maximbilan / InstagramWallPost.swift
Created July 24, 2016 06:11
iOS Instagram Wall Post
let image = UIImage(named: "example")
let instagramURL = NSURL(string: "instagram://app")
if UIApplication.sharedApplication().canOpenURL(instagramURL!) {
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
let saveImagePath = (documentsPath as NSString).stringByAppendingPathComponent("Image.igo")
let imageData = UIImagePNGRepresentation(image!)
do {
try imageData?.writeToFile(saveImagePath, options: NSDataWritingOptions(rawValue: 0))
} catch {
print("Instagram sharing error")
@scrivy
scrivy / create cert.txt
Created July 17, 2016 07:17
self signed https localhost proxy with golang
copied from https://devcenter.heroku.com/articles/ssl-certificate-self
install go and openssl
mac os x: brew install go openssl
Generate private key and certificate signing request
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
@ericelliott
ericelliott / class-constructor-factory-examples.js
Last active August 28, 2023 18:18
Class, Constructor, Factory
// class
class ClassCar {
drive () {
console.log('Vroom!');
}
}
const car1 = new ClassCar();
car1.drive();
@mattdw
mattdw / unlitspriteshader.js
Last active August 5, 2020 20:14
a sprite shader for THREE.js which doesn't need to clone textures, by storing its own repeat/offset
import THREE from "lib/three";
const params = `
varying vec2 vUv;
uniform vec2 offset;
uniform vec2 repeat;
uniform sampler2D texture;
uniform vec3 color;
`
@guiyomh
guiyomh / oracle_db_install.rsp
Last active August 23, 2024 14:04
Install Oracle 11gR2 on centos7 x86_64
####################################################################
## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##