Skip to content

Instantly share code, notes, and snippets.

@nepsilon
nepsilon / how-to-find-the-pid-of-a-process-using-a-given-port.md
Created December 27, 2016 02:54
How to find the PID of a process using a given port? — First published in fullweb.io issue #80

How to find the PID of a process using a given port?

Sometimes you have a process you lost the PID, and would like to kill it.

You can use top (or better htop) to search for your process name and press k to kill it. But this isn’t optimal when you aren’t sure of its name. A better alternative is to search by the port opened, for example port 80:

sudo lsof -i :80
@alexclifford
alexclifford / s3_set_object_public.sh
Created July 24, 2015 01:59
Make S3 object public and private via s3cmd command line
s3cmd setacl s3://bucket/path/to/file --acl-public
s3cmd info s3://bucket/path/to/file
s3cmd setacl s3://bucket/path/to/file --acl-private
@vipickering
vipickering / closestNumberArray.js
Created September 13, 2013 15:42
Javascript: Find The Closest Number In Array To A Specific Value
var array = [];
function closest(array,num){
var i=0;
var minDiff=1000;
var ans;
for(i in array){
var m=Math.abs(num-array[i]);
if(m<minDiff){
minDiff=m;
<?php
declare(ticks = 1);
class TimeoutException extends Exception {};
function signal_handler($signal) {
throw new TimeoutException();
}
@lxcodes
lxcodes / gist:1010364
Created June 6, 2011 14:27
Set Cursor at the End of a ContentEditable
function setEndOfContenteditable(contentEditableElement)
{
var range,selection;
if(document.createRange)//Firefox, Chrome, Opera, Safari, IE 9+
{
range = document.createRange();//Create a range (a range is a like the selection but invisible)
range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range
range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
selection = window.getSelection();//get the selection object (allows you to change selection)
selection.removeAllRanges();//remove any selections already made