Skip to content

Instantly share code, notes, and snippets.

@victornpb
victornpb / deleteDiscordMessages.js
Last active April 16, 2024 09:32
Delete all your messages from DM or Channel in Discord
/*
This file is now hosted here:
https://github.com/victornpb/undiscord
*/
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@PatrickJS
PatrickJS / factory-shared.es5.js
Last active January 6, 2024 04:18
Different examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between…
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};
EventEmitter.call(person);
person.wallet = 0;
_.extend(person, personMethods)
return person;
@eatnumber1
eatnumber1 / renameat2.c
Last active November 3, 2023 17:24
Command-line tool to call renameat2(2)
/*
* Copyright (c) 2023 Russell Harmon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@CatTail
CatTail / htmlentity.js
Created November 30, 2012 08:27
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@jkjustjoshing
jkjustjoshing / $inject.user.js
Last active December 6, 2021 16:32
Angular $inject userscript.
// ==UserScript==
// @name AngularJS Injector
// @namespace http://joshkra.me/
// @version 0.1
// @description Binds $inject method to window
// @author jkjustjoshing
// @match *://*/*
// ==/UserScript==
// This userscript creates an $inject() method on the window object that can be used to
@calzoneman
calzoneman / termimg.c
Created January 13, 2018 07:54
Display images (in true color!) in a compatible terminal emulator using block characters
#include <gd.h>
#include <stdio.h>
#include <string.h>
void process(gdImagePtr img) {
for (int j = 0; j < img->sy/2; j++) {
for (int i = 0; i < img->sx; i++) {
int top = gdImageGetPixel(img, i, j*2 );
int bottom = gdImageGetPixel(img, i, j*2 + 1);
@benfoxall
benfoxall / MutationObserverLogger.js
Created December 5, 2012 18:10 — forked from pgchamberlin/MutationObserverLogger.js
Snippet that logs DOM mutations using the MutationObserver API
<script type="text/javascript">
// See MDN: https://developer.mozilla.org/en-US/docs/DOM/MutationObserver?redirectlocale=en-US&redirectslug=DOM%2FDOM_Mutation_Observers
(function(){
// select the target node
var target = document.querySelector('body');
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var i={};
// create an observer instance
var observer = new MutationObserver(function(mutations) {