Skip to content

Instantly share code, notes, and snippets.

@todgru
todgru / elasticsearch-setup-apple-macbook-pro-m1.md
Created February 9, 2023 23:52
Install Elasticsearch 7.x on Apple Macbook Pro M1 Ventura 13.2

Elasticsearch Setup Apple MacBook Pro M1

Apple MacBook Pro M1, 32 GB, Ventura 13.2

Documentation based on comments in this Github Elasticsearch issue.

Install Homebrew

@robozavri
robozavri / php sort array by closest lat and lng coordinates
Created June 27, 2018 12:45
php Search or sort multi dimensional array for closest lat and lon values
<?php
$arrGeoData = array(
array(
"zipcode" => 777,
"latitude" => 37.234982,
"longitude" => -82.913799,
"cityname" => "tiflis",
),
array(
"zipcode" => 666,
@juhaelee
juhaelee / react-typescript.md
Last active January 26, 2023 00:52
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)

@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@badsyntax
badsyntax / default
Last active December 5, 2023 23:10
My basic nginx config files for proxying to a node.js application
server {
listen YOUR_IP_ADDRESS:80 default_server;
root /var/www/nginx;
index index.html index.htm;
# This is just an invalid value which will never trigger on a real hostname.
server_name _;
server_name_in_redirect off;
@roshanbh
roshanbh / download-file-from-http.php
Last active December 7, 2023 07:31
Download remote files (on http url ) using curl and PHP
<?php
//$file - should contain full url
// $newFileName - full physical path directory with file name
function getFile($file, $newFileName)
{
$err_msg = '';
echo "<br>Attempting message download for $file<br>";
$out = fopen($newFileName, 'wb');
if ($out == FALSE){
print "File not opened<br>";
@bradwright
bradwright / websockets-server.js
Created June 11, 2011 23:29
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <brad@intranation.com>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');