Skip to content

Instantly share code, notes, and snippets.

View daniel12fsp's full-sized avatar

Daniel Pereira daniel12fsp

View GitHub Profile
@johnatandias
johnatandias / listenToAllEvents.js
Last active June 25, 2020 23:25
Listen to all events
(() => {
Object.keys(window).map(property => {
if (property.startsWith('on')) {
window[property] = event => console.log('=>', event.type, { event })
}
})
})()
#!/bin/bash
# Realy simple and easy script for automatic background change of gnome shell screensawer wallpaper
# Install:
# 1. put this script somewhere
# 2. set script executable (chmod +x unsplash.sh)
# 3. add script to your crontab (crontab -e) [0 * * * * YOUR_PATH/unsplash.sh >/dev/null 2>&1]
PWD=$(dirname $(readlink -f $0))
@johnhamm
johnhamm / tasks.json
Created January 19, 2017 20:41
webpack webpack-dev-server problem matcher for vscode
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "silent",
"args": ["run"],
"tasks": [{
"taskName": "dev",
"isWatching": true,
"isBuildCommand": true,
@suyash
suyash / client.c
Created January 2, 2017 15:53
UDP echo client-server implementation
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
int main() {
const char* server_name = "localhost";
const int server_port = 8877;
@anhldbk
anhldbk / README.md
Last active February 27, 2025 07:18
TLS client & server in NodeJS

1. Overview

This is an example of using module tls in NodeJS to create a client securely connecting to a TLS server.

It is a modified version from documentation about TLS, in which:

  • The server is a simple echo one. Clients connect to it, get the same thing back if they send anything to the server.
  • The server is a TLS-based server.
  • Clients somehow get the server's public key and use it to work securely with the server

2. Preparation

@kirilloid
kirilloid / type.js
Last active July 29, 2022 19:42
getType
function getType (value) {
let type = typeof value;
if (type === 'object') {
return value ? Object.prototype.toString.call(value).slice(8, -1) : 'null';
}
return type;
}
[NaN, 0, 1, Infinity, // numbers
null, undefined, false, 'str', // other primitives
@dozoisch
dozoisch / linc.sh
Created June 16, 2015 18:11
Run Lint Only on Changed files
git diff -z --name-only --diff-filter=ACMRTUB `git merge-base HEAD master` | xargs -0 eslint
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active April 1, 2025 08:06
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');