Skip to content

Instantly share code, notes, and snippets.

View ilomon10's full-sized avatar
🐢
keep a beloved undangon - stay tuned!

Imanuel Pundoko ilomon10

🐢
keep a beloved undangon - stay tuned!
  • manjo
  • Manado, Sulawesi Utara, Indonesia
  • X @ilomon10
View GitHub Profile
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 20, 2024 11:27
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');
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@iclanzan
iclanzan / components.md
Last active May 4, 2024 01:57
UI Component Name Ideas

UI component names

As front-end developers we all know the pain of coming up with meaningful component names for CSS classes. I created this gist as a place to collect terms that are suitable as user interface component names.

Please contribute your own ideas!

Interactive components

  • button
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@sid24rane
sid24rane / net.js
Last active May 19, 2024 07:28
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
var net = require('net');
// creates the server
var server = net.createServer();
//emitted when server closes ...not emitted until all connections closes.
server.on('close',function(){
console.log('Server closed !');
});
@rodrigobaron
rodrigobaron / install-opencv.sh
Last active April 21, 2023 18:51
Install OpenCV on Ubuntu or Debian
# SOURCE: (milq) https://github.com/milq/scripts-ubuntu-debian/blob/master/install-opencv.sh
# also http://milq.github.io/install-opencv-ubuntu-debian/
# KEEP UBUNTU OR DEBIAN UP TO DATE
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
@Kaundur
Kaundur / canvasDownload.js
Created June 8, 2017 07:25
JS to automatically download canvas as a png
// This code will automatically save the current canvas as a .png file.
// Its useful as it can be placed in a loop to grab multiple canvas frames, I use it to create thumbnail gifs for my blog
// Only seems to work with Chrome
// Get the canvas
var canvas = document.getElementById("canvas");
// Convert the canvas to data
var image = canvas.toDataURL();
// Create a link
var aDownloadLink = document.createElement('a');
@Xananax
Xananax / TextFit.tsx
Created February 11, 2018 11:34
React Element for fitty.js
import * as React from 'react'
import { Component } from 'react'
import fitty, { Options, Fitted } from 'fitty'
export type Props = Partial<Options> & {text?:string} & React.AllHTMLAttributes<HTMLSpanElement>
export const style =
{ display: `inline-block`
, whiteSpace: `nowrap`
}
@jeffjohnson9046
jeffjohnson9046 / kill-all-connections-to-db.sql
Created June 18, 2018 18:10
How to kill all connections to a Postgres database
-- Accepted answer from here: https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-connections-to-it
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '[your database name goes here]'
AND pid <> pg_backend_pid();
@talyguryn
talyguryn / wildcard-ssl-certificate.md
Last active October 29, 2023 08:57
How to get a wildcard ssl certificate and set up Nginx.

How to get and install a wildcard SSL certificate

In this guide you can find how to resolve the following issues.

Feel free to ask any questions in the comments section below.