Skip to content

Instantly share code, notes, and snippets.

@nasitra
nasitra / image.svg
Created May 23, 2016 10:30
Access JavaScript function in SVG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nasitra
nasitra / Flatland Dark.tmTheme
Last active June 28, 2016 13:22
Insert color scheme settings to Flatland theme for Sublime Text 3 (build 3103)
...
<dict>
<key>name</key>
<string>Entity.name.label</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F8F8F8</string>
@nasitra
nasitra / server.rb
Created May 10, 2016 11:44
Broadcast server implemented with Ruby
require 'em-websocket'
require 'webrick'
EM.run {
@clients = []
EM::WebSocket.start(:host => '0.0.0.0', :port => '3001') do |ws|
ws.onopen do |handshake|
@clients.push ws
end
@nasitra
nasitra / app.js
Created May 10, 2016 11:43
Broadcast server implemented with Node.js
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function(ws) {
ws.on('message', function(message) {
wss.clients.forEach(function(client) {
client.send(message);
});
});
});
@nasitra
nasitra / client.go
Created May 9, 2016 13:30
Broadcast server implemented with Go and WebSockets
package main
import "github.com/gorilla/websocket"
type client struct {
socket *websocket.Conn
room *room
send chan []byte
}
@nasitra
nasitra / refresh.html
Created May 2, 2016 02:22
Use meta refresh to redirect to a new page
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta http-equiv="refresh" content="0; url=http://example.com/">
</head>
<body></body>
</html>
# email
mailto:?subject=Title&body=http%3A%2F%2Fexample.com
# tweet
https://twitter.com/share?text=Title&url=http%3A%2F%2Fexample.com
# share on Facebook
https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fexample.com
@nasitra
nasitra / foo.cpp
Created March 4, 2016 10:56
Test C++ code by using Go language
#include <iostream>
#include "foo.h"
void Foo::print() {
std::cout << "foo\n";
}
extern "C" void Foo_print() {
Foo t;
@nasitra
nasitra / double_to_enum.c
Created January 18, 2016 10:11
Inconsistent result from assignment the negative double value to an enum-type variable
#include <stdio.h>
typedef enum {
ZERO
} NUM;
int main(void) {
double a = -1.0;
NUM b = a;
@nasitra
nasitra / outlook_mail_subjects.js
Created December 25, 2015 09:29
Collect mail subjects from Outlook in Windows
var outlook = WScript.CreateObject('Outlook.Application');
var olFolderInbox = 6;
var nameSpace = outlook.GetNamespace('MAPI');
var folder = nameSpace.GetDefaultFolder(olFolderInbox);
var isOpend = !!outlook.ActiveWindow;
if (!isOpend) {
folder.Display();
outlook.ActiveWindow.WindowState = 1