How To: Free Computer

How to: Free Computer

via AWS Elastic Compute Cloud

The modern world is so rich and tangible. We all have access to an unlimited cache of knowledge and power, just like a bad Syfy Channel movie.  If that wasn’t enough to make you love life, Amazon will warm your cold heart. They give anyone in the world a free computer. If you have internet at least. I’ll show you how to get one, and how to setup your new ‘machine’ to start doing your bidding.

Step 1.

Go to http://aws.amazon.com/ec2/ Click the “Try Amazon EC2 For Free” Button. The shiny one. Screen Shot 2015-07-02 at 3.10.47 PMOr sign-in to Amazon and go to your EC2 Dashboard via AWS Management Console.Screen Shot 2015-07-02 at 3.16.01 PM

Step 2.

From the EC2 Dashboard, click Launch Instance. This will show you a list of Server OS’. Choose one that fits your feet and on to step 3.

Remember to select the “Free Tier Only” Checkbox.

Screen Shot 2015-07-02 at 3.18.18 PMScreen Shot 2015-07-02 at 3.19.05 PM

Step 3.

Choose an Instance Type. The Free Tier is usually the cheapest one of the bunch. You can easily upgrade later. You can launch your instance now or configure it further. The other options are more advanced and you don’t need to mess with them yet.

If you understand SSH, consider configuring your security settings. You can whitelist ip addresses to enable only certain machines to SSH into your new E2 instance. Launch when ready!
Screen Shot 2015-07-02 at 3.22.15 PM

Step 4.

Here is the cool part. How does Amazon protect your computer from just anyone? PGP. Amazon will give you a private key file. This file is just like a key. Every time you want to log-in to your instance, Amazon will request this file. It’s extremely important that you keep this .pem document safe. Probably not a good file to keep on the desktop.

Screen Shot 2015-07-02 at 3.34.21 PM

Step 5.

Ding! You’re up and running and it’s time to rock. Connecting to this baby is a piece of candy. You’re going to SSH in like normal. However, you also need to send your .pem private key. On the top-left of the EC2 console, you will see a link to Connect. This opens a panel displaying all the info you need to open a tunnel. From here you can also use a SSH console from in the browser. Really neat.

ssh -i /path/to/key ec2-user@instance.ip

Screen Shot 2015-07-02 at 3.58.11 PM

Bam. I like to make aliases to stuff like this.

Screen Shot 2015-07-02 at 3.38.55 PM

Once connected you should see something like this:

Screen Shot 2015-07-02 at 3.39.23 PMThis is a good time to install any updates.

Step 6.

There you go, we have a literally free computer. It’s powerful too. Here’s an example of some fun stuff you can do with even the free instances. I made a TwitterBot that retweets random people based on a random subject. Using this instance, I can run this script via cronjob. Because it’s on the cloud I don’t have to worry about if my laptop is on or not. Now replace this script with spiders or mailers or anything. Really cool potential.

Screen Shot 2015-07-02 at 3.47.25 PMScreen Shot 2015-07-02 at 3.50.48 PM Screen Shot 2015-07-02 at 3.48.01 PM

All and all this is extremely cool to me. Thanks Amazon for such awe-inspiring goodness. I’m excited to continue experimenting with EC2!

Learning Regex: Lesson One

Read this:

(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ 
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 00-
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 00-31]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(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:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
 \t])*(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
)*(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
"()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])
+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 00-31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
?:\r\n)?[ \t])*))*)?;\s*)

You now understand Regular Expressions. A particular tool for a particular job. Have fun.

How to: Set up a cron job (For Wizards)

Today I set up a cron job for the laughs. The documentation I found was lacking. Here’s my go at it.

Cron is a unix utility written by Paul Vixie. Thanks Paul for a great utility. Cron jobs are simple to make and extremely useful. They allow you to run any kind of task you want at anytime. Say you want to run a script that emails your buddy every 30mins. That sounds perfect, and cron can do it perfectly. Let’s write a script that curls a website, and we will call it with a Cron every 59 mins.

Setting up a Cron is pretty simple. For this tutorial I’m assuming you are running on Unix. Sorry Windows folks.

The first step is to write your crontab file. This file schedules your Crons. They are formatted like so:

min hour day month week command

(*)s are wildcards. That means it will run every time it can. So if you wanted to run something every minute instead of every 59, just put a *. Or lets say you want to run it once a day at 10:30.

30 10 * * * /Users/jim/Documents/hello.py

This is an example I’ve written. It will run every 59 mins of every day, every month, every week, forever.

Screen Shot 2013-12-30 at 6.03.25 PM

Forever.

Every 59 mins it runs your command. My command is to run a shell script. You can make any command you want of course. You can make a command to email your buddy every minute of everyday forever. You should definitely write that.

Now lets set up your cron. You can find you Crons in several ways.

Terminal:      sudo -i cd /var/at/tabs

crontab:         crontab -l

Screen Shot 2013-12-30 at 6.24.10 PM

You should check these out and see what you have running, if anything, before moving forward. You probably don’t have anything running, so let’s making something.

Using you favorite editor write a txt file formatted as I’ve shown above. When do you want your cron to run? Cron checks your crontab file every minute, but I would recommend deleting this cron after you’ve played around. DON’T DO CRAZY STUFF HERE.

You should make a file like thus: ‘what.cron.txt’ or something similar. Its contents should look like thus:

30 * * * * /Users/An/myshittyhacks/myshittyscripts/emailMyBoy.frnd.py

This crontab will run every 30 mins. Or:

* * 25 12 * /Users/blackhertdeathsoul/Vitaliysmomscode/merryxmas.sh

This crontab will run every minute on December 25.

Upload your crontab file with the crontab command:    crontab path.your.cron.file

Screen Shot 2013-12-30 at 6.40.53 PM

For my cron, I wrote a shell script that calls this ruby script. I wrote a sh wrapper because I was scared. However it’s not necessary.

Screen Shot 2013-12-30 at 6.33.47 PM

Screen Shot 2013-12-30 at 6.04.17 PM

 

 

Now you’re done. They way I did this was hacky and bad, however this will get your computer to run code on a schedule! Have much fun.

The Way of Testivus

If you write code, write tests.
Don’t get stuck on unit testing dogma.
Embrace unit testing karma.
Think of code and test as one.
The test is more important than the unit.
The best time to test is when the code is fresh.
Tests not run waste away.
An imperfect test today is better than a perfect test someday.
An ugly test is better than no test.
Sometimes, the test justifies the means.
Only fools use no tools.
Good tests fail.

Boids, Flocking, and Unapologetically Plastic

I found a great algorithm for AI Flocking behavior. It’s actually an old algorithm with a very popular example called Boids. Boids are objects that emulate fish or bird flocking behavior. I fell in love with a Java Processing example of this algorithm. The effect is simple and really beautiful.

Flocking with Processing

The Boids actually appear to be a flock of animals. They respond to each other somewhat perfectly. The collision, and slowly drifting gives the Boids a realistic appearance.

I also really like this example project written in cocoa2d by Onedayitwillmake.com. I re-wrote it with spritekit as fast as I could. I wrote it too fast because I could only create 80 Boids before the framerate became shitty. The original project was able to have over 200 sprites at almost 60 frames. I’m still investigating why my performance is so much lower. Screen Shot 2013-09-19 at 4.26.32 PMGit

Thanks Onedayitwillmake for the great example.

I bought the iPhone 5C and I’m going to cram my opinion of it into the internet. It’s great! I got the green one and I really like it.

Spritekit

So Spritekit is coming out next week most likely. I’ve been test driving this new whore trying to see how hardcore it is.

It’s pretty awesome!

Not too hardcore and sexy; Spritekit is easily lovable. It’s easier and cleaner than Cocos2D. For a noob like myself it was really simple to get started and make something; even under the NDA. I’ve used both cocos2D and Spritekit. Honestly I’m not sure how they compare though. I wrote a really small cocos2D “game” a few years ago and it wasn’t too difficult to add collisions and sprites. However in Spritekit it’s ridiculously easy. I only needed a few lines of code to create a rain effect with pure nodes. This weekend I’m going to try to use a genetic algo to generate sprite children and see what interesting things I can do.

 

Image 

 

 

Git

echo -e “\e[32m”; while :; do printf ‘%*c’ $(($RANDOM % 30)) $(($RANDOM % 222)); sleep 0.001; done

Screen Shot 2013-08-19 at 3.08.59 PM

I’ve finally learned how git works. I’ve been using it for week and I never understood it. After getting destroyed on every merge for a month it finally dawned on me. My friend Randall explained it to me for the 10th time and it finally became crystal clear. I CAN SEE CLEARLY NOW THE RAIN IS GONE! Git is a beautiful program and extremely useful! All the commands I had been using for weeks suddenly became the best things ever. I hated Git two weeks ago now I love it.

I learned some really sexy aliases for Git.

git log –graph –pretty=’format:%h | %an | %s’
git log –graph –oneline –abbrev-commit
git log –pretty=format:’%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s’ –date=iso

thanks Vitaliy

“Hacking is bad, m’kay.”

I thought that it would only take me one more day for me to finish this CMS my company is building. 4 hours of code later everything is broken. 2 weeks of hard coding and hacking in every feature finally caught up to me. One thing breaks and you’re fucked. Without tests you can’t even tell whats breaking it.

Every problem I faced I just blew over with some retarded hacks. For instance, I have an array of all the products that I use to display the images and metadata. Then it becomes necessary to implement pagination. So I decide to just create a new array for every page. Then my indexing arrows don’t work. My genius inspired me to just multiply the index by the amount of products on the page, and then add the index.

Prefect code.

I’m then I added a jquery plugin to colorbox a menu and everything is fucked. What??!?! Another 4 hours of code later and my partner and I broke everything. We are straight gangsters. One last day of work becomes another week of work and way off schedule.

37845862

function showDCDetails(index)
{
	var pageOfChains = dcPagination(currentDcPage* dcPageSize, dcPageSize, allDC);
	var dc = pageOfChains[index];
	all_dc_index = ((currentDCPage * 7) + index);
	
	var all_dc = allDC[all_dc_index];
	console.log("allDC[all_dc_index]  ", allDC[all_dc_index]);
	var test = allDC[index];
	selected_dc = all_dc;
	$("#dc_chain_ul").empty();
	$("li").click(function() {
		$("a",this).addClass("selectedRow").parents().siblings().children().removeClass("selectedRow");
	});
	if (currentDcPage == 0) {
		$("#dc_title").val(dc.chainName);
	}else{
		$("#dc_title").val(all_dc.chainName);
	}
	
	
	// console.log("total items:",dc.items);
	console.log("HELLOOOOO", all_dc.items);
	
	for(var j = 0; j < all_dc.items.length; j++) 
	{
		console.log("ITEMS", all_dc.items);
		var row = $('<li></li>');
		if(j%2 == 0)
		{
			if (all_dc.items.length > 3) 
			{
				$("#deleteDCProductButton").show();
				$("#deleteDCProductButton").attr("onclick", "onRemoveProductPressed(\""+selected_dc.chainId+"\")");
			}
			else
			{	
				$("#deleteDCProductButton").hide();
			}

			// product
			var product = all_dc.items[j];
			populateRowWithProductIdAndIndex(product.productId,j);
			row.append($("<a><img id='prodRow"+j+"' onclick='showProductsForSelection("+j+")' src='img/no_product.png' width='320px' height='568px'></img></a>"));
			
		}
		else
		{
			// story
			var story = all_dc.items[j];
			row.append($("<textarea id='storyText"+j+"' onchange='onDCStoryChanged("+j+")' class='prodTextArea' rows='3'>"+story.body+"</textarea>"));
			
		}
		$('#dc_chain_ul').append(row);	
	}
}

JS Sucks, Genetic Algorithms, and Rate my Yoga Instructor

Spent the last week making a webapp with js.node. I don’t like js.

I’ve become really interested in Genetic Algorithms. Machine learning is very powerful and I know I can use it to make something great. I just haven’t thought of anything concrete yet. I’ve started playing around with Xcode 5 and iOS7, and I used them to run this algo I found. The process is real simple. It take user inputed string and run checks on every character. Lets call the user inputed string theString. The algo counts all characters in theString. Then, for every character it generates a random character. It checks each character for how close it is to the same character at index in theString. So if theString at index 0 == “t”, it will check how close the generated character is to that. It then assigns a negative value for every character and adds them. Now the fun part.

<Screen Shot 2013-07-25 at 9.16.43 PM

This part is better than sex. The algo does this 750 times. The algo makes all neighboring strings breed. The breeding is simple. Out of the two strings, the string who is the most “fit” is passed on. Then a new string is made with a random mutation chance. That means that every character in the string has a small chance of changing to a random character. Every child string is put in an array and the most “fit” in that array is the Champion. Now we generate another 750 and do it all over again. The Champion of that group is compared to the new contender. The victor becomes the Champ.

Then some exciting shit happens. It does this loop until one the the Champions has a fitness value of 0. That Champion is equal to theString. This small algorithm doesn’t do anything very useful but it’s a interesting first step toward smart algorithms and machine learning.

I’m also making an iOS app with my friend called, “Rate my Yoga Instructor”.

DMCA’ed and Ducks

This is a notification that your application, Dragon Ball Z HDTV, with package ID com.liyicky.dbzhd, has been removed from the Google Play Store.

REASON FOR REMOVAL: Alleged copyright infringement (according to the terms of the Digital Millenium Copyright Act).

All violations are tracked. Serious or repeated violations of any nature will result in the termination of your developer account, and investigation and possible termination of related Google accounts. If your account is terminated, payments will cease and Google may recover the proceeds of any past sales and the cost of any associated fees (such as chargebacks and payment transaction fees) from you.

Please review the Developer Distribution Agreement and Content Policy to ensure that your applications are compliant with our policies.

The DMCA is a United States copyright law that provides guidelines for online service provider liability in case of copyright infringement. Click here for more information about the DMCA, and see http://www.google.com/dmca.html for the process that Google requires in order to make a DMCA complaint.

Google may reinstate your application into the Google Play Store upon receipt of a counter notification pursuant to sections 512(g)(2) and (3) of the DMCA. Click here for more information about the requirements of a counter notification and a link to a sample counter notification. If you have legal questions about this notification, you should retain your own legal counsel.

Please note that we have included a text copy of the Infringement Notice we received for your reference.

The Google Play Team

And that’s how DBZ HDTV ended.

I’ve been writing a lot of python. I’m such a noob. It’s like playing league before you know that minions OP. I don’t write any subclasses. I don’t understand why I would want to make a subclass. I’m prob just a genius or something. Only nerds write subclasses. I don’t understand what the hell a super class is supposed to do. What the hell does __init__() do? One thing that’s finally dawning on me is problem with types in python. That shit fucks me up so much.

For instance:

class Bomb:
    def __init__(self):
        ""

    def talk(self):
        self.explode()

    def explode(self):
        print "BOOM!, The bomb explodes."

class Duck:
    def __init__(self):
        ""
    def talk(self):
        print "I am a duck, I will not blow up if you ask me to talk."    

class Kid:
    kids_duck = None

    def __init__(self):
        print "Kid comes around a corner and asks you for money so he could buy a duck."

def takeDuck(self, duck):
    self.kids_duck = duck
    print "The kid accepts the duck, and happily skips along"

def doYourThing(self):
    print "The kid tries to get the duck to talk"
    self.kids_duck.talk()

myKid = Kid()
myBomb = Bomb()
myKid.takeDuck(myBomb)
myKid.doYourThing()
#Copy and Pasted from Dmitry from StackOverflow

http://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python

Python is my best friend. It lets me do whatever I want. Even when I will get myself in trouble. I are excite though. I’m just starting to take my first baby steps into intermediate python. Let’s see how much this bites. Pun.end()