Skip to content

Instantly share code, notes, and snippets.

View toanalien's full-sized avatar
🎯
Focusing

Thiên Toán toanalien

🎯
Focusing
View GitHub Profile
@toanalien
toanalien / gist:baca180b2a036f1a8d05
Last active August 29, 2015 14:24
demo chatbox via tcp by nodejs
/**
* @toanalien
*/
var net = require('net');
var server = net.createServer();
var sockets = [];
server.on('connection', function(socket) {
console.log('got a new connection');
@toanalien
toanalien / 1437027969.cpp
Last active August 29, 2015 14:25
100 - The 3n + 1 problem
#include <stdio.h>
int main()
{
unsigned long int x,z,i,j , n, max;
while (scanf("%lu %lu", &x, &z) == 2)
{
if (x > z)
{
i = z;
#include <stdio.h>
int main()
{
int z = 123456;
while (z/10 !=0)
{
printf("%d", z%10);
z = (z-z%10)/10;
}
printf("%d", z);
@toanalien
toanalien / gist:a2db3b528f3172895b3a
Last active August 29, 2015 14:25
flip number function
#include <stdio.h>
int flip_number(int n)
{
int temp = 0;
while (n/10 !=0)
{
temp += n%10;
temp*=10;
n = (n-n%10)/10;
}
@toanalien
toanalien / .cpp
Created July 21, 2015 04:28
Letter Combinations of a Phone Number
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
* Return an array of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
int slip_num(int num)
{
@toanalien
toanalien / .js
Created August 4, 2015 18:30
joinRoom
function joinRoom(socket, room) {
socket.join(room);
currentRoom[socket.id] = room;
socket.emit('joinResult', {room: room});
socket.broadcast.to(room).emit('message', {text: nickNames[socket.id] + 'has joined ' + room + '.'});
var usersInRoom = io.sockets.clients(room);
if (usersInRoom.length > 1) {
var usersInRoomSummary = 'Users currently in ' + room + ': ';
for (var index in usersInRoom) {
var userSocketId = usersInRoom[index].id;
@toanalien
toanalien / .cpp
Created August 15, 2015 17:59
cafe
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
ifstream cinFile;
ofstream coutFile;
int n, a, b, c, somon, bien = 0;
@toanalien
toanalien / cafe_fina.cpp
Created August 15, 2015 20:06
cafe_fina
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
fstream f, f_out;
int n, a, b, c, somon, bien = 0;
@toanalien
toanalien / cafemini.cpp
Created August 16, 2015 05:45
cafemini.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
fstream f, f_out;
int n, b, c, somon;
@toanalien
toanalien / gist:141f9b14444247c90bc9
Created August 19, 2015 08:00
nmap wimesh vpn2
Starting Nmap 6.49BETA4 ( https://nmap.org ) at 2015-08-19 14:56 SE Asia Standard Time
Nmap scan report for mainserver.wi-mesh.com (10.0.0.1)
Host is up (0.0020s latency).
MAC Address: 00:25:90:CA:9B:66 (Super Micro Computer)
Nmap scan report for vpn1.wi-mesh.com (10.0.0.2)
Host is up (0.0010s latency).
MAC Address: 00:25:90:CA:9B:56 (Super Micro Computer)
Nmap scan report for vpn2.wi-mesh.com (10.0.0.3)
Host is up (0.0020s latency).
MAC Address: 0C:C4:7A:0F:33:B2 (Super Micro Computer)