Sign up to get extra content & updates via email!

Thanks for signing up!
I appreciate it!

AgriCatch source released

AgriCatch-logoHello everyone!
Today is a great day to release some projects to the wild!

AgriCatch is a data aggregation tool I’ve built on top of Django.
What AgriCatch does is pretty simple – it lets you grab data from wild and disorganized websites (talking about the HTML of course).

It supports

  • XPath – use XPath to find different fields
  • Pagination – if you’d like to grab a list of things that are paginated, that’s also possible
  • Custom functions – if you’d like to do something special with the fields before saving them to DB
  • Leftover event related functionality – originally AgriCatch was designed for events, because of that there’s some leftover functionality in that matter:
    • days_on_page – you can give the timespan within the events of a single page are included (for example if it’s a weekly page – 7)
    • start_day & num_of_days – you can give the importer a default starting day, it will then attempt to replace the url with a timestamp (according ot a format mentioned in the website template). Example:
      http://www.example_events.com?date=%m-%d-%Y
      Would then try to move forward days_on_page days until it reached the limit (num_of_days).
  • HTML & XML support

Most of the useful documentation for building importers is found in the Repository under agricatch/website.py
To import you simply run the command:

python manage.py doimport website_name --days=7

website_name refers to the name of the website in lowercase!

More info to come..

Tagged with: , , ,
Posted in Technology

Nexus 6, Android 5, and a Chrome tip

This post will be short, very short (sorry).
So, what happened yesterday? Nexus 6 was announced!

Not only that, Android 5’s name is finally revealed,
as many people guessed it: Lollipop is the name.

I’m afraid 5 inches for a Smartphone is my max, so I won’t be replacing my Nexus 5 anytime soon (maybe make some flexible screens? I’m daydreaming).

Within a few weeks we got the iPhone 6 and the Nexus 6 announced, with similar names and flagship products of both companies, this is definitely a head-to-head battle.
With a 13MP camera, I’m very interested in knowing if the Nexus can finally beat the iPhone when it comes to taking pictures.
Here’s some interesting bit of information: The best camera (bar none) is actually on the Lumia, which is a Windows Phone!

At any rate, phoneArena, being super fast as always, already made some nice comparison of the two devices.

Now for a small tip!

if you’re having problems with this annoying chrome inspector panel (happens on newer versions):
chrome_inspector

 

 

You can hide that by simply clicking on the “Toggle device mode” button:
chrome_inspector1

Tagged with: , , , , ,
Posted in Technology

Github’s Student Developer Pack

A few days ago, I’ve stumbled upon a short title on HackerNews: GitHub Student Developer Pack.

GitHub's Student Developer Pack, awesome!

GitHub’s Student Developer Pack, awesome!

At first I thought “oh cool, so they’re giving some discounts for GitHub accounts”.
Little did I know how Massive this thing is.

Let’s start with what GitHub is giving you:
github_micro

5 Private repositories as long as you’re a student, not bad (more than enough for most people)!

This isn’t even close to being the best deal in the Pack, here are some of the best ones in my opinion:

  • DigitalOcean: 100$ Free!! This is enough for 20 months using their smallest Droplet (512MB RAM, enough for most basic websites), or 10 months using their 1GB RAM droplet!
  • Namecheap: Free .ME domain for 1 year from (8.99$ worth is not much, but it’s perfect to get students started building their own website)
  • Namecheap: Free SSL certificate for a year (again, 9$ worth, but crucial for making a solid e-commerce website, these days it’s recommended for most SaaS products)
  • Stripe: speaking of e-commerce, how about No Fees on your first 1000$ in revenue?
  • Orchestrate.io: Database as a service, interesting concept to take care of the entire database for you, Developer account (max 50 Million API calls, 149$/mo) as long as you’re a student!
  • Travis CI: Continuous integration, mostly for automating the different tests you should do before introducing new features to your code base (Unit tests, Selenium tests, whatever), you get Free private builds (69$/mo) as long as you’re a student!

 

There are a few more, but I have to say these are the ones I found most impressive.
I’ve started looking into places that give you discounts/offers if you’re a student, and found out that the guys from BitBucket give you their Unlimited plan (Unlimited users to share your code with, everything else is unlimited on all plans for BitBucket).

BitBucket in general is pretty awesome, because you have unlimited private repos for free.
I would definitely recommend working on BitBucket for private repositories, and using GitHub for open source projects (mainly because it gets a lot more traffic).

That’s about it for this week, I’d be happy to hear of some other companies that join GitHub in its mission to help students and get them started with Web Development.

Tagged with: , , ,
Posted in Technology

Creating custom Media Upload for WordPress

Insert MediaIn a custom plugin I made, I had to add a custom media upload button in order to make sure only a single Video file is can be selected.
After doing some research, I discovered the handy & pretty undocumented component: wp.media

Just to make sure we’re on the same page, this is a JavaScript component which is a part of WordPress, used to handle Media upload (when writing a post).
If you’re not sure how to add fields/buttons within post editing, take a look at the add_meta_boxes action, just so you can understand the context.
 
Let’s start with a simple upload button:

<input type=”button” value=”Upload Video” class=”upload_vid” />

And the following JS snippet:

jQuery( 'body' ).on( 'click', '.upload_vid', function(e) {
	e.preventDefault();
	var foo = wp.media();
	foo.open();
});

This will simply open up a Media Upload dialog (with the default configuration), it won’t be that functional because we’re not doing anything with the selected media yet.

We’d like to only be able to select a single Video file, so here are the relevant changes (for the sake of brevity I only show the wp.media() line, the rest is the same for now):

var foo = wp.media({
	library     : { type : 'video' },
	multiple    : false
});

As you can probably guess, the 1st line limits to videos, and the 2nd disables multiple select.
Let’s also add some title & custom submit button text:

var foo = wp.media({
	title       : AWESOME Video Upload Title!',
	button      : { text : ‘Add this AWESOME video!' }
	library     : { type : 'video' },
	multiple    : false,
});

Cool, ok now we have a custom upload dialog, all that’s left is to actually do something with the submitted videos.
wp.media has an event called close, we can access the frame using that, let’s add the following event (still inside the onclick event) + html:

HTML:

<input type=”button” value=”Upload Video” class=”upload_vid” />
<span class=”id_of_vid”></span>
<span class=”link_to_vid”></span>

JS:

foo.on( 'close', function() {
	var videos = foo.state().get( 'selection' ).toJSON();
	jQuery( ‘.id_of_vid’ ).text( videos[0].id );
	jQuery( ‘.link_to_vid’ ).text( videos[0].url );
} );

This will show you the ID of the selected video inside the id_of_vid span (and the URL on the other span), obviously the object inside videos[0] has Title, Filename, and so on, so you can do whatever you’d like with it.

What about saving your selection?

Let’s utilize the fact that we have the ID inside the id_of_vid span, to make sure the video is already selected when re-opening the dialog (this time, using the open event):

foo.on( 'open', function() {
	var selection = foo.state().get( 'selection' );
	var vids = jQuery( ‘.id_of_vid’ ).text();
	if ( vids !== '' ) {
		attachment = wp.media.attachment( vids );
		attachment.fetch();
		selection.add( attachment ? [ attachment ] : [] );
	}
});

As you can see this is a bit complex, but at the end of the day we’re using the selection object we used earlier, and adding to it an attachment object (created using the ID inside id_of_vid).

I hope I’ve given enough tools so everyone can make some custom wp.media widgets, this would’ve definitely saved me a lot of trouble a few days ago.

See you next week!

Tagged with: , , , ,
Posted in Technology

Automate WordPress with WP CLI

wp-cliHow long does it take you to install a new WordPress website?
Do you have a collection of plugins you constantly use for every WordPress website you install? Does the same go for themes?
What about some dummy data? Do you have to add some posts and pages every time?

What if you want to automate some commands on the admin panel (like custom cron jobs, replacing brand name, adding a list of users)?

In comes WP CLI

WP CLI is basically a power tool for WordPress developers.
It lets you do almost everything that you do on your WordPress admin panel from the command line, with some awesome extras.

To create a WP website:


wp site create --slug="simpsons" --title="Simpsons Blog" --email="bart@simpsons.com" --private

This will create a private website (not indexed) titled Simpsons Blog (slug is simpsons), where the admin’s email is bart@simpsons.com

 

Scaffold

I just love this command! It lets you generate PHP code for creating post types, taxonomies, as well as themes & child themes!

Tip Time!
If you ever make changes to a WordPress theme you have,
never make them directly on the theme itself, if you do, after updating the theme your changes will often be gone! Plus that’s not a good way of keeping with encapsulation.
Instead, create a child theme which “inherits” the design and functions of your parent theme and builds on top of them.

 

Scaffold has a command that lets you generate a child-theme with a single command:

wp scaffold child-theme kidsil --parent_theme=twentyfourteen

This would create a theme with the slug kidsil, whose parent theme is TwentyFourteen.


Export

I’d recommend running exports of your posts as a Cron Job, on top of normal DB & Website backups, WP exports take up less space, as well as don’t take as long to run.
It also takes less time to import them back to your website (depending on how much data you have).

The simplest export command (just exports everything):

wp export --dir=/tmp/

As you can see, this exports to /tmp/. The output XML file is named:
WEBSITE_NAME.wordpress.2014-09-25.0.xml

But if we’re running a Cron job every week, why should we copy the same posts again and again?
Let’s run a command that only gets last week’s posts (some bash magic over here):

wp export --start_date=$(date +"%Y-%m-%d" --date="-7 day")

Pretty neat right? All you have to do is run it as a Cron job and there you have it, Automatic backups!

There are a lot of very useful commands, for taxnomies, users, transients, widgets and sidebars to name a few. I definitely recommend digging into the wonderful documentation.

I hope I gave everyone a few ideas on how to potentially use WP CLI.
Until next week!

Tagged with: , , ,
Posted in Technology

Birthday pause!

Happy Birthday from Google

got a Happy Birthday from Google

I know I promised a post about WP CLI (and it’s coming, don’t worry),
but it just so happens that today’s my Birthday!

In the past 3 years I’ve celebrated each Birthday in a different country,
I hope to keep this streak going in the years to come.

 

The post will be coming next week!

 

And here’s a cute video:

Tagged with:
Posted in Uncategorized
Welcome to KidsIL
A blog for Web Development & Technology


Check out my new series about MeanJS: Take a look at StartCast.
A podcast with the sole purpose of interviewing co-founders of Startups in Europe & around the world.


You should try Berlin On Feier, an App I built for finding the best parties in Berlin.