Shared posts

11 Nov 13:30

Mustache templates in C

Leandro Pereira

Shameless plug :)

Generating textual output is a lot easier with templates than it is with handcrafted functions. And it is a lot easier in languages such as Python, where things like introspection are easy and cheap. But that doesn’t necessarily mean we can’t do that in C if we know where to look.

I’ve implemented a subset of Mustache templates in C that leverages some tricks that makes template rendering both convenient and efficient. For instance, if you have a template such as this:

Hello, {{name}}!

It can easily be rendered with the following code:

hello_t data = {
.name = "World"
};
lwan_tpl_render(hello, &data);

Where hello is the template that was previously compiled into a series of simple instructions (such as append text or append the value of a variable), and the second parameter is a structure containing the data needed by the renderer.

My first thought to render these templates would involve the use of a hash table. While reasonably efficient (even considering the overhead to create and destroy the table every time the template had to be rendered), they’re not first class citizens in C, and the usage would be pretty clumsy, to say the least:

hash_table *ht = hash_table_new();
hash_table_add(ht, "name", "World");
lwan_tpl_render(hello, ht);
hash_table_free(ht);

Instead, I’ve decided to go on another road: use standard C structures to store the values in their native form, and then find a way to lookup these values whenever necessary to render the template.

The first trick, then, was to use a C99 feature called compound literals, which is supported by GCC even in C89 mode. This trick allows the use of anonymous arrays, among other things, and provides enough syntactic sugar to conveniently group the template variables:

lwan_tpl_render(hello, (hello_t[]) {{
.name = "World"
}});

Without a way to lookup which value to obtain from the structure, however, this would not help much. Enter the second trick: the offsetof(3) macro, which computes the offset of a field in a given structure. By storing this offset alongside data type information, the value lookup is not only possible but can also work with types different than strings:

typedef struct hello_t {
char *name;
int age;
};
/*
* The TPL_VAR_??? macros provides some convenience to declare each
* descriptor. These expand to a declaration containing the name of
* the variable as a string (used to validate the template during
* compile time), the field offset, and pointers to functions that
* convert the values to string and check if they're empty.
*
* The SENTINEL type is there so the template compiler knows when to
* stop looking for descriptors, since of course you can have as many
* fields as necessary.
*/
lwan_var_descriptor_t hello_descriptor[] = {
TPL_VAR_STR(hello_t, name),
TPL_VAR_INT(hello_t, age),
TPL_VAR_SENTINEL
};
lwan_tpl_t *hello;
strbuf_t *rendered;
/*
* ``hello'' would usually be compiled once and kept around for
* the whole duration of the program.
*/
hello = lwan_tpl_compile("hello.tpl", hello_descriptor);
/*
* Rendering the template then would be just the matter of calling
* this function, which will output a ``strbuf_t''. The template
* compiler estimates the starting size of this string buffer, so
* rendering will incur in very few expensive reallocations, if
* there are reallocations at all.
*/
rendered = lwan_tpl_render(hello, (hello_t[]) {{
.name = "World",
.age = 42
}});
printf("%s\n", strbuf_get_buffer(rendered));
strbuf_free(rendered);

Code for this engine is available in the wip branch of my toy web server, lwan. It is not currently used there, but it is built alongside the main program and can be tested by invoking the generated template executable.

Before using that in lwan, though, I’ll try to employ this nifty trick to JIT-compile the template and avoid some of the overhead where it really matters. While at the same time possibly opening a whole can of worms from the security standpoint, though – but it wouldn’t be fun without some risk, would it? :)

09 Nov 10:58

prostheticknowledge: Windswept by Charles Sowers  Art...





prostheticknowledge:

Windswept by Charles Sowers 

Art installation fixed outside a gallery’s wall, displaying natural flow and turbulence of the wind - via dezeen:

Hundreds of spinning blades reveal the invisible patterns of the wind in American artist Charles Sowers’ kinetic installation on the facade of the Randall Museum in San Francisco.

The installation, titled Windswept, consists of 612 rotating aluminium weather vanes mounted on an outside wall. As gusts of wind hit the wall, the aluminium blades spin not as one but independently, indicating the localised flow of the wind and the way it interacts with the building.

“Our ordinary experience of wind is as a solitary sample point of a very large invisible phenomenon,” said Sowers. “Windswept is a kind of large sensor array that samples the wind at its point of interaction with the Randall Museum building and reveals the complexity and structure of that interaction.”

You can find out more at Dezeen here, with photos and a video of the work in action.

07 Nov 09:54

From Very Important To Very Impotent

by admin

(Convenience Store | Salt Lake City, UT, USA)

(I am a customer in line at a convenience store. Customer #1, the lady in front of me in line, is complaining loudly about everything, from the slow service (which wasn’t slow at all) to the way the young clerk is dressed. Finally, Customer #2, the man in front of her, turns around.)

Customer #2: “I’m sorry if I’m being forward, ma’am, but, may I ask your name?”

Customer #1: *proudly states her name*

Customer #2: *relieved sigh* “Oh, thank God! Don’t scare me like that, lady!”

Customer #1: “…What do you mean?”

Customer #2: “For a minute there, I thought you were someone who’s opinion mattered! Now I know you’re just a windbag I can safely ignore!”

(Customer #1 didn’t make a sound until she left!)

03 Nov 10:56

Gaming Travel Stickers

by René

Schöne Reiseaufkleber für Real Life-Taschen damit man damit angeben kann, wieviele virtuelle Welten man besucht hat: „Where have you been in videogames lately? Document your gaming journey with these individual gaming luggage labels. High quality vinyl suitable for outdoor use. All aboard!“

Gaming Luggage Labels (via Albotas)

03 Nov 10:49

Pinball Porn

by René
Leandro Pereira

Ooohhh, shiny

Youtube Direktpinball, via Laughing Squid

Totally had me at the Twilight Zone-Machine with Robby the Robot.

01 Nov 19:31

Vita sales continue to disappoint as Sony scales back expectations

by Kyle Orland
Leandro Pereira

Daqui a pouco o PS Vita fica raro -- alguém quer comprar o meu enquanto isso não é verdade? Vai com Uncharted, cartão de memória e carrying case oficial.

Back in May, Sony was confident that its newly launched Playstation Vita and aging PlayStation Portable would combine for a robust 16 million in sales for the fiscal year. Three months later, having sold only 1.8 million portable systems, the company lowered that forecast to 12 million units. Now, after another quarter of weak sales, the company has scaled back expectations yet again, reducing its projection to 10 million portable systems for the year ending March 31, 2013.

Worldwide, Sony sold 1.6 million portable systems in the last three months, less than the 1.7 million PSPs it sold during the same period last year, before the Vita was even on the market. While Sony didn't reveal specific sales numbers for the Vita and PSP separately, it seems pretty clear that Sony expected its newer portable system to make up for declining PSP sales. Instead, the weak portable performance has helped drag Sony's game segment to a ¥1.3 billion ($16.2 million) loss for the first half of the fiscal year, down from a ¥7.1 billion ($88.6 million) profit last year.

Sony's report comes just a week after Nintendo also lowered sales expectations for the 3DS by 1 million units for the year, citing tough competition from mobile and tablet games. It seems both companies were overly optimistic about the market demand for dedicated portable game hardware in a world now dominated by smartphones, tablets, and 99¢ downloadable games.

Read 2 remaining paragraphs | Comments

29 Oct 16:41

Programming on an Arduino without a PC

Leandro Pereira

Só por ter "Arduino" no título a palestra foi aceita pro FISL -- o HardInfo, outro projeto livre meu, que até saiu em revista e ganhou prêmio, foi rejeitado várias vezes... uma, inclusive, disseram que eu não tinha competência técnica pra falar sobre o meu programa :P

I’ve attended this year’s FISL, both as a booth attendee (at ProFUSION’s booth, demonstrating a few of our end-user-visible projects), and as a speaker for my old FINF project.

FINF is a Forth-like programming environment that I’ve written in my first year at the college. It’s not the first compiler I wrote, but it was the first that was actually fun to write. Some years later, I’ve decided to rewrite it so that it would work on the Arduino – and that’s what I went to FISL to talk about.

audience

Arduinos are traditionally programmed by using its IDE, in a language that resembles C++. In fact, it is C++, but some of the (boring) details are hidden. But, being C++, it’s bound to the slow write-compile-upload-test procedures; there’s no interactive prompt, such as you have with Python or the venerable 8-bit Microsoft Basic. And since Arduino is all about experimentation, an interactive prompt is a must.

FINF is there to fill this gap. It is not a full FORTH implementation; only a small subset of it is there, but it’s enough to blink some LEDs, make some noise, and – if a video output shield is used – use the Arduino as an 8-bit computer! But, since user code actually runs on top of a very simple virtual machine due to the Harvard architecture used by the AVR microcontroller, it’s not possible to expand the interpreter without getting dirt in your hands. Add that to the quite messy code, mix it with myself not being a good marketer, and you have yet another failed open source project of mine! :)

In any case, the slides (in Portuguese) are available online. Unfortunately, the presentation was not recorded, so if you were not there, you’ve missed the great opportunity of seeing myself making a LED blink in front of an audience.

(By the way, I’ll be talking during EFL Developer Day in Barcelona early next month. If you’re there for LinuxCon/Embedded Linux Conference and would like to join me for some beers, don’t hesitate to contact me!)

28 Oct 01:12

RC Airplane Made from Political signs

by Jeremy Cook

V1-Full

Whatever candidate (if any) you’re in favor of, we could bet that you’re probably tired of seeing advertisements and political signs everywhere. [Mark] wrote in with a hack that allows you to actually use these signs for something fun, making a RC airplane!

[Mark] gives a full bill of materials in his article, but the featured component is campaign sign. This isn’t LawyerADay, so we’re not sure of the legality of taking them. After election day at least, it’s doubtful anyone will care. Of course you’ll also need a motor, prop, and RC controls, as well as some dowels to attach the tail section to the main body, so don’t buy the “campaign promise” that this is a free airplane.

CAD diagrams are available of the cutouts, as well as how to cut the signs to form hinges without any other parts. This is quite clever, and a video of the plane in action on a table is available on the site. According to [Mark], no video was rolling on its test flight, but it did fly before some interference grounded the plane. Hopefully he’ll be able to get some footage of it in action soon!


Filed under: toy hacks


26 Oct 10:44

Baumgartner Headshot, GIF’d

by René

Hab ich gestern schon getwittert, muss aber auch hier rein: „I hate soccer but this is awesome“. And it is.

26 Oct 00:40

Experts Warn About Security Flaws In Airline Boarding Passes

by samzenpus


concealment writes in with a story about a newly found security issue with the bar codes on boarding passes. "Flight enthusiasts, however, recently discovered that the bar codes printed on all boarding passes — which travelers can obtain up to 24 hours before arriving at the airport — contain information on which security screening a passenger is set to receive. Details about the vulnerability spread after John Butler, an aviation blogger, drew attention to it in a post late last week. Butler said he had discovered that information stored within the bar codes of boarding passes is unencrypted, and so can be read in advance by technically minded travelers. Simply by using a smartphone or similar device to check the bar code, travelers could determine whether they would pass through full security screening, or the expedited process."

Share on Google+

Read more of this story at Slashdot.

24 Oct 23:38

Spiders in The Office

Spiders in The Office

Submitted by: Unknown

Tagged: spiders , projection , yikes , giant , mindwarp , gifs Share on Facebook
24 Oct 02:02

What The Melon?

Submitted by: Unknown

Tagged: gifs , watermelon , explosion , wtf
23 Oct 14:00

Photo



23 Oct 12:45

Video



22 Oct 20:07

Finally, turning plastic pellets into 3D printer filament

by Brian Benchoff

Here’s the situation: a kilogram of 3D printer filament costs about $50. A kilogram of plastic pellets costs less than a tenth of that. Does anyone have a solution to this problem?

For years now, the general consensus was making your own 3D printer filament at home was nigh impossible, dealing with temperatures, pressures, and tolerances that home-built machines simply can’t handle. [Bradley] sent in a filament extruder he made because he was disturbed at this current mindset that desktop filament factories have huge technical issues that have yet to be overcome.

[Bradley]‘s extruder is based on the Lyman Filament Extruder, a machine that has successfully demonstrated taking plastic pellets, forming them into a filament, and having this filament used in the production of 3D printed parts. [Bradley]‘s improvements include a variable-speed motor, a larger hot end, and an automatic timing system to produce set quantities of printer filament.

Of course, since Inventables threw $40,000 at the problem of creating filament at home there were bound to be more than a few successful designs making their way out into the public. When we last covered the developments of home filament manufacturing, the Filabot seemed to be in the lead. Now with [Bradley] (and  [Lyman])’s machines turning out usable filament, it’s only a matter of time before the 40 grand prize is snatched.


Filed under: 3d Printer hacks


22 Oct 11:50

That Andy's a right drama queen...

22 Oct 11:48

godblessgig-emandhooah: babywarrior5: mccunt: stangefruitandwi...



godblessgig-emandhooah:

babywarrior5:

mccunt:

stangefruitandwildthing:

Geraldine Hoff Doyle, was a 17 years (in 1942) while she was working at the American Broach & Machine Co. when a photographer snapped a pic of her on the job.

That image used by J. Howard Miller for the “We Can Do It!” poster, released during World War II. 

Oh shit, that’s the real “Rosie the Riveter” ?

BAMF

BAMF INDEED. This woman deserves all the respect in the universe!

Beyond awesome. Much kudos to you, ma’am.

20 Oct 21:44

Learning neuroscience with cockroach legs

by Brian Benchoff

Neuroscientists [Tim Marzullo] and [Greg Gage] wanted a way to get kids interested in neuroscience. What they came up with isn’t terribly far from something found in Frankenstein’s lab; by amputating a cockroach’s leg and attaching electrodes, they’re able to listen to the sound of neurons firing. For an even cooler demonstration, they’re able to apply a little bit of current to the leg and make the leg dance to the beat of the Beastie Boys.

The guys published an article in PLOS One and gave a TED talk demonstrating their SpikerBox, as they call their invention, to the masses. The basic idea is to amplify the electricity generated by cockroach neurons firing. By listening in on the neurons with an iPad app, [Tim] and [Greg] can set the threshold of the recording to detect the action potential of an individual neuron, and listen in on exactly what happens when a single neuron fires.

It seems like a great tool to explain the very basics of what a nervous system – and a brain, both cockroach and human – actually is. In the video after the break, you can see [Greg] playing around with individual cockroach neurons. After that, [Greg] plays the Beastie’s High Plains Drifter into the leg making the muscles contract. Truly, The Sounds of Science.


Filed under: Medical hacks


19 Oct 19:44

Brainfuck JIT Compiler in Around 155 Lines with GNU C

by noreply@blogger.com (Matthew Plant)
Leandro Pereira

Um monte de truque legal aí. :D

In my last post I illustrated how JIT compilation can be achieved using GNU C with very little assembler (in that case, only one line). However, although I just claimed the contrary, it didn't really give an example JIT compilation, only JIT loading. Here I finally rectify that by providing an extremely unpolished Brainfuck compiler, using the previously illustrated methods. A few things to note about the example, before I dive into (and barely explain anything):
  • Because I didn't want to deal with reallocating and whatnot, the program just allocates and anonymous mapping of some sort of random size (MAX_PROG_SIZE). 
  • Because I didn't want to do relative jumps, I just set the desired jump address to %EAX and used a register-indirect jump. This means that the code could definitely simplified a whole lot, but made my life a lot easier.
  • The code I used to test this was the default hello world program supplied by Wikipedia and this snazzy Mandelbrot viewer.
  • The code only works on 32 bit systems; notice how I used only unsigned int. Yeah that's indicative of something. 
  • If you want to see the entire program, including test cases (of which there are only two), a Github repo is available here.
Warning: the code in this article is an example of DEEP MAGIC.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <sys/mman.h>

#define MAX_LOOPS 1000
#define STACK_SIZE 1000
#define MAX_PROG_SIZE (1024 * 10000) /* I don't know */

unsigned char *
find_jmp(unsigned char *d, size_t size)
{
unsigned int prev;
unsigned char *l;

prev = 0;
do {
l = memchr(d + prev, 0xd5, size - prev);
assert(l != NULL);
prev++;
} while (l[1] != 0xda ||
l[2] != 0xad ||
l[3] != 0xde);
return l;
}

void
compile_and_run(char *code)
{
void *dyn;
unsigned int mem_used;
unsigned int prev, curr, after;
unsigned int j_sp;
unsigned int j_stack[MAX_LOOPS]; /* Jump locations, used during compilation. */
unsigned int bf_sp; /* Brainfuck stack pointer. */
unsigned int bf_stack[STACK_SIZE]; /* Brainfuck stack. */
int (*getchar_a)(void) = &getchar; /* Alias of getchar. */
int (*putchar_a)(int) = &putchar; /* Alias of putchar. */
unsigned char *d, *loc;

#define COPY_SECTION(sec_s, sec_e, dest) do { \
unsigned char *buf; \
mem_used += &&sec_e - &&sec_s; \
if (mem_used > MAX_PROG_SIZE) { \
fprintf(stderr, "Maximum program size exceeded!\n"); \
abort(); \
} \
for (buf = &&sec_s; buf < &&sec_e; buf++, (dest)++) \
*(dest) = *buf; \
} while (0)

bf_sp = 0;
memset(bf_stack, '\0', sizeof(int) * STACK_SIZE);

/* Allocate memory. */
mem_used = 0;
dyn = mmap (0, MAX_PROG_SIZE,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

/* Compile the program. */
d = dyn;
j_sp = 0;
memset(j_stack, '\0', sizeof(int) * MAX_LOOPS);

for (; *code; code++)
switch (*code) {
case '>':
COPY_SECTION(inc_sp, dec_sp, d);
break;

case '<':
COPY_SECTION(dec_sp, inc_se, d);
break;

case '+':
COPY_SECTION(inc_se, dec_se, d);
break;

case '-':
COPY_SECTION(dec_se, inp, d);
break;

case ',':
COPY_SECTION(inp, outp, d);
break;

case '.':
COPY_SECTION(outp, loop_enter, d);
break;

case '[':
j_stack[j_sp++] = (unsigned int) d;
COPY_SECTION(loop_enter, loop_exit, d);
break;

case ']':
prev = j_stack[--j_sp];
curr = d;
COPY_SECTION(loop_exit, jump_end, d);
after = d;
loc = find_jmp(prev, &&loop_exit - &&loop_enter);
loc[3] = (after >> 24) & 0xff;
loc[2] = (after >> 16) & 0xff;
loc[1] = (after >> 8) & 0xff;
loc[0] = after & 0xff;
loc = find_jmp(curr, &&jump_end - &&loop_exit);
loc[3] = (prev >> 24) & 0xff;
loc[2] = (prev >> 16) & 0xff;
loc[1] = (prev >> 8) & 0xff;
loc[0] = prev & 0xff;
break;

default:
break;
}

/* Copy over the jump back: */
COPY_SECTION(jump_end, end, d);

/* Now call the code. */
goto *dyn;

/* Instructions: */
inc_sp: /* Increment stack pointer. */
bf_sp++;
dec_sp: /* Decrement stack pointer. */
bf_sp--;
inc_se: /* Increment stack element. */
bf_stack[bf_sp]++;
dec_se: /* Decrement stack element. */
bf_stack[bf_sp]--;
inp: /* Get one byte of input. */
bf_stack[bf_sp] = getchar_a();
outp: /* Print one byte. */
putchar_a((int)bf_stack[bf_sp]);
loop_enter:
if (!bf_stack[bf_sp]) {
asm volatile("movl $0xdeaddad5, %eax");
asm volatile("jmp *%eax");
}
loop_exit:
asm volatile("movl $0xdeaddad5, %eax");
asm volatile("jmp *%eax");
jump_end:
asm volatile("jmp *%0" :: "r" (&&end)); /* Jump to the end of the function. */
end:
munmap(dyn, MAX_PROG_SIZE); /* Free the data and return. */
return;
}

I'm not going to go in to much detail on how exactly this works, as all of the mechanics are noted in my previous blog. However, there is one part worth explaining, that is what happens when we get to a closing bracket ']'. Whenever we get to a place where we need to jump, we write out the instructions to jump to some random location. In this case, that location is 0xDEADDAD5. This is because we don't know where exactly we are to jump yet. Then, when we do figure out, we find the location of memory where we load 0xDEADDAD5 into %EAX and change that value to the correct address. Sound confusing? Yeah I can't really explain it well. Sorry about that.

Anyway, I hope you found this interesting. I sort of did?
15 Oct 23:35

Vectored I/O with mmap() to serve files

Leandro Pereira

Comecei um blog novo e tenho falado um pouco sobre alguns truques que tenho usado em um "pet project" (um servidor HTTP).

Previously, I’ve improved file serving performance in lwan by dramatially cutting down on the number of system calls performed to serve a file. However, for small files (< 16KiB), the throughput drop from the hello handler (which merely responds “Hello, World!”) was significant, since lwan was still performing system calls to open, obtain the size, and close the file.

I’ve experimented with userland caching before, but it never occurred to me to use mmap(). For the unitiated, this system call offers a way to map a file into memory, by giving a pointer to the process virtual memory space, that, when dereferenced, will perform the necessary disk I/O if the pages were not already present in the kernel buffers. Wikipedia has more details about it. Using mmap() greatly simplifies caching code by relaying it to the kernel, closer to where the low level buffers are.

By using a memory-mapped buffer and writev() (which the hello handler uses through lwan’s abstractions), the file serving performance improved about 60%! Before the optimization, weighttp would be able to make ~170000 requests/s. Now, ~286000 requests/s can be made. (That’s on my laptop, a Core i7 2640m, with 8GiB of RAM and without spinning platters.)

Of course, introducing caching also introduces a lot of complexity. Not only the file serving handler almost doubled its size (from 350 lines to 610 lines), but I’ve had to add a hash table implementation (with around 430 lines) and a directory watcher that uses inotify at around 150 lines of C code. In the order of 840 lines of code to improve performance by about 60%. About 30% more lines of code to improve performance in 60% – not bad, methinks.

On the other hand, the cache mechanism brings shared mutable state. This is protected by mutexes, of course, but I’m not sure if I got it right. One more reason to not use lwan in production.

As a bonus to these things, lwan now offers deflated content for the files in the cache when asked.

15 Oct 17:39

ez Share Wireless Transmission Wi-Fi SDHC Memory Card - Orange (4GB / Class 4)

Leandro Pereira

Estava demorando pra clonarem o Eye-Fi...

ez Share Wireless Transmission Wi-Fi SDHC Memory Card - Orange (4GB / Class 4) SKU #: 160262, Price: US$47.20 free shipping - Brand: ez Share
- Model: ES200
- Quantity: 1
- Color: Orange
- Material:
- Type: SD card
- Capacity: 4GB
- Read Speed: 8.9MB/s
- Write Speed: 5.13MB/s
- Class: 4
- Wi-Fi: IEEE802.11b/g/n
- Support browser: Safari / US / IE / OPERA / Chrome / QQ
- Transmission distance: 5~10m (Indoor), 25~50m (Outdoor)
- Supports simultaneous access users: 5
- Terminal support iPhone, iPad, smart phone, tablet PC, notebook and other device with Wi-Fi function.
- Wi-Fi password: 8888 8888
- To switch off the share mode you need to turn off the share switch
- Browser and App access mode
- Great for connecting your Wi-Fi device with camera and uploading your photos to the internet anywhere
- Packing list:
- 1 x SD card
- 1 x Chinese / English user manual

Add To Cart Add To Wish List
15 Oct 13:04

Cats’ Free Fall from Space, GIF’d

by René

Based on this flying Feline. Also: Felix Baumgartners Jump from Space, recreated in Lego. (via Reddit)

11 Oct 17:04

Hackaday’s portal gun actually levitates a companion cube

by Caleb Kraft

I was out to lunch with a couple friends, brainstorming ideas for fun projects when one of them says “Wouldn’t it be cool if we could build a working gravity gun?”. We all immediately concurred that while it would in fact be cool, it is also a silly proposition. However, only a few seconds later, I realized we could do a display piece that emulated this concept very easily. Floating magnetic globes have been around for quite some time.

I determined I would tear the guts out of a stock floating globe and mount it on a portal gun, since they’re easier to find than a gravity gun. I would also build a custom companion cube to be the correct size and weight necessary.

The Levitation System

I started off with a StellaNova magnetic levitating globe. I chose the larger version that is roughly 8″. My assumption was that this one would be able to hold a little more weight than the smaller version.

Prying the coil out of the metal frame turned out to be difficult and actually resulted in a damaged coil that I had to repair. If you were to replicate this, I’d suggest cutting the entire metal case that contains the coil from the frame instead of trying to remove just the coil.

Once I had the coil out, I tore the strong magnet out of the top of the globe. This globe actually has a magnet in the base that helps stabilize it during levitation so I knew I was going to have to tweak my companion cube to get the weight just right. As you can see, my process is purely scientific and extremely precise.

The portal gun

I really wanted to make my own portal gun for this. My schedule and my ego fought hard on this subject and ultimately my schedule won. While I feel like I could have built a fantastic portal gun, there’s no way I could have done it in a reasonable amount of time and gotten as nice of results as just buying the portal gun props available at toy stores.

When initially mounted the coil on the gun, I found that the “arms” were far too flexible. I had to reinforce the arm somehow. The option I chose was simply to bend a piece of steel to the correct shape and strap it to the underside of the “arm”.

I made a cardboard model to test weight and size of the companion cube and got the system working on the portal gun.

The Cube

At this point, the entire thing is working. I’m far too excited to wait for some kind of store bought cube to arrive and attempt to get it to the correct weight. That’s assuming I could find one the right size. So, I made my own out of foam. Admittedly, it isn’t the best looking companion cube in the world.  If I were to take this further, I’d probably sculpt one and make a mold so that I could make my own solid foam companion cube.

A single huge improvement:

I started off thinking that the final product would be a portal gun that you could hold while it levitated a cube. This meant that I needed to actually mount the coil that suspends the floating cube on to the portal gun. As you can see in the video, it is a fairly visible modification. You can see the coil, wires, and reinforcement on the top arm of the portal gun. Once it was built however, I found that I couldn’t hold it still enough to maintain the levitation.

Since holding it is officially not going to happen, I realized I could have done this in a more aesthetically pleasing manner. Instead of using the type of  floating globe that dangles the magnet below a coil, I could have used one with a magnetic base that floats the magnet above the coil. This would have left the portal gun completely un-modified.

Thanks

I wanted to give a special thanks to Vintage Stock in Springfield Missouri (the one on Glenstone), who let me bring the system in and show it off until the hall effect sensor finally got smashed too many times and the cube wouldn’t levitate.


Filed under: news


09 Oct 14:13

Stickin' It to the Man!

Stickin' It to the Man! One passive-aggressive apology at a time!

Submitted by: Unknown

Tagged: cashier , diabetes , fast food , fat , obesity , sticking it to the man Share on Facebook