Skip to content

Instantly share code, notes, and snippets.

[perryh@03381-1-1368994 ~]$ gem install eventmachine
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/home/perryh/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
int potPin = 2; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor
void setup() {
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
Serial.println(val);
/**
* Main game loop that will begin allowing turns and also polls input for moves
* also will send moves to client and await client response
*/
public static void game_loop() throws Exception{
String clientSentence;
ServerSocket server_socket = new ServerSocket(2000);
Socket connection = server_socket.accept();
PrintWriter connection_output = new PrintWriter(connection.getOutputStream(), true);
* Main game loop that will begin allowing turns and also polls input for moves
* @throws IOException
* @throws UnknownHostException
*/
public static void game_loop() throws UnknownHostException, IOException {
StringTokenizer st = null;
String sentence = null;
Socket client_socket = new Socket("localhost", 2000);
PrintWriter connection_output = new PrintWriter(client_socket.getOutputStream(), true);
[perryh@localhost Assignment2.0]$ ruby map_query.rb
__ __ _ _
\ \ / / | | | |
\ \ /\ / /__| | ___ ___ _ __ ___ ___ | |_ ___
\ \/ \/ / _ \ |/ __/ _ \| '_ ` _ \ / _ \ | __/ _ \
\ /\ / __/ | (__ (_) | | | | | | __/ | |_ (_) |
\/ \/ \___|_|\___\___/|_| |_| |_|\___| \__\___/
____ _ ___ _ __ ___ ____
@perryh
perryh / gist:5061207
Created February 28, 2013 23:53
Nice & useful clang error output
stream_client_itimer.c:107:59: error: use of undeclared identifier 'MSG_NOWAIT'; did you mean 'MSG_DONTWAIT'?
sent = send(socket_fd, output_buffer, frame_size, MSG_NOWAIT);
^~~~~~~~~~
MSG_DONTWAIT
/usr/include/bits/socket.h:215:5: note: 'MSG_DONTWAIT' declared here
MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
^
1 error generated.
class Fixnum
def palindrome?
return self.to_s == self.to_s.reverse
end
def square_of_palindrome?
sqrt = Math.sqrt(self)
return sqrt.to_i.palindrome? && sqrt - sqrt.to_i.to_f == 0
end
end
@perryh
perryh / disqus.haml
Last active December 16, 2015 10:09
Disqus HAML embed
#disqus_thread
:javascript
/**
* var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
*/
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'YOURSITE.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
@perryh
perryh / client.cpp
Last active December 16, 2015 16:09
real-time multimedia simulation client & server
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>