Skip to content

Instantly share code, notes, and snippets.

nextid = 0
# websocketserver takes a path to bind to, optional options object and a callback.
wsserver = websocketserver '/ws', (client) ->
# The callback is called when a client connects, with a handler for the client object.
# The user is responsible for adding ids to the client object if they need them.
client.id = nextid++
console.log "client #{client.id} connected with websocket version #{client.protocolVersion}"
<?php
$fp = stream_socket_client( "tcp://address:port", $error, $errorstr, 60 );
if(!$fp){ printf( "%s (%d)", $errorstr, $error ); }
$i = 0;
while($i++ < 100){
$message = sprintf( "%03d message\n", $i );
fwrite( $fp, $message );
print $message;
}
@edwintroyano
edwintroyano / server.php
Created January 19, 2020 06:26 — forked from ninehills/server.php
php socket server
<?php
require("sql.php");
//确保在连接客户端时不会超时
set_time_limit(0);
//设置IP和端口号
$address = 'localhost';
$port = 2009;
@edwintroyano
edwintroyano / server.php
Created January 19, 2020 06:26 — forked from ninehills/server.php
php socket server
<?php
require("sql.php");
//确保在连接客户端时不会超时
set_time_limit(0);
//设置IP和端口号
$address = 'localhost';
$port = 2009;
@edwintroyano
edwintroyano / IMAP_access.php
Created January 2, 2020 01:15 — forked from nmcgann/IMAP_access.php
IMAP access class to decode imap body, fetch and assemble all the parts and attachments. Used as an utility class for processing a whole mailbox.
<?php
/**
* IMAP_access. Utility class for processing a mailbox for applications that
* want to grab the body text and do something with it e.g. create a new
* todo list item. Enough clues in there that it can be expanded to do
* a lot more if required - e.g. also grab file attachments.
*
* Based on several part-working tutorials (fixed), the PHP manual examples
* and testing on real email samples from Gmail, Thunderbird and MS outlook 2010.
* (flatten_parts is the tricky bit and was from here:
@edwintroyano
edwintroyano / index.html
Created December 21, 2019 05:05 — forked from WickyNilliams/index.html
parseTable.js - convert HTML table to array of objects. MIT licensed (https://opensource.org/licenses/MIT)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>parseTable</title>
</head>
<body>
<table>
<thead>
<tr>
@edwintroyano
edwintroyano / AJAXTable.js
Created December 21, 2019 04:54 — forked from lukebiggerstaff/AJAXTable.js
A script to create a mobile first responsive table using AJAX and vanilla javascript
var getTableDataAJAX = function() {
var getTableData = new XMLHttpRequest();
getTableData.onreadystatechange = function() {
if(getTableData.readyState === 4) {
var tableInfo = JSON.parse(getTableData.responseText);
var tableHeading = tableInfo.tableHeading;
var tableCellsPets = tableInfo.tableCellsPets;
var tableCellsPeople = tableInfo.tableCellsPeople;
@edwintroyano
edwintroyano / NumeroALetras.js
Created December 19, 2019 13:16 — forked from alfchee/NumeroALetras.js
Código en JavaScript que convierte números a letras, bastante útil para formularios de documentos contables y similares
/*************************************************************/
// NumeroALetras
// The MIT License (MIT)
//
// Copyright (c) 2015 Luis Alfredo Chee
//
// 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>WebKit contentEditable focus bug workaround</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>WebKit contentEditable focus bug workaround</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){