Skip to content

Instantly share code, notes, and snippets.

View ghalusa's full-sized avatar
🤓
Geekin'

Goran Halusa ghalusa

🤓
Geekin'
View GitHub Profile
@ghalusa
ghalusa / node-load-tweet.js
Created May 17, 2013 19:59
node-load-tweet
/**
* Script dependencies
*/
var twitter = require('ntwitter');
var settings = require('./config.js');
var exec = require('child_process').exec;
var twit = new twitter({
consumer_key: settings.consumer_key ,
@ghalusa
ghalusa / parse_a_rendered.php
Created May 16, 2013 11:36
Parsing anchors in rendered html with php
<?php
$url = "http://www.imdb.com/movies-in-theaters/";
$input = @file_get_contents($url) or die("Could not access file: $url");
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if(preg_match_all("/$regexp/siU", $input, $matches)) {
// $matches[2] = array of link addresses
// $matches[3] = array of link text - including HTML code
echo "<pre>";
var_dump($matches[2]);
echo "</pre>";
The objective of this post is to get you from absolutely nothing, to a fully functional nodejs environment.
Software used: Ubuntu 11.10, Nodejs v0.6.12, Nginx, MongoDB, Redis, and NPM modules.
1. Download and install the latest version of Ubuntu: http://www.ubuntu.com/download (don't select any extra items to install when prompted)
2. Once you are logged in and are at your Ubuntu command prompt, install the necessary software you will need:
a. sudo apt-get install openssh-server
b. sudo apt-get install libssl-dev
c. sudo apt-get install git
d. sudo apt-get install g++
e. sudo apt-get install make
@ghalusa
ghalusa / random_rows
Created May 8, 2013 03:43
Efficiently Selecting Random Rows From a MySQL Table
public function getRandomRecords()
{
// Select the first id in the target table
$statement = $this->db->prepare("SELECT some_id
FROM table_name
ORDER BY some_id ASC LIMIT 1");
$statement->execute();
$lowest_id = $statement->fetch(PDO::FETCH_ASSOC);
// Select the last id in the target table
@ghalusa
ghalusa / dynamic_port_forwarding.md
Created April 9, 2015 17:34
Dynamic Port Forwarding

To access a server, behind a firewall, via HTTP...

Use a server you have access to, as a proxy...

ssh -N -D 9000 user@server

Configure your web browser to use SOCKS proxy host 127.0.0.1 and port 9000.

@ghalusa
ghalusa / wellcome_player_install_run.md
Last active August 29, 2015 14:18
Wellcome Player Installation and Run

Installation + Run: 4/1/2015

NPM: Globally Installed List

ghalusa@player:~$ npm list -g --depth=0
/usr/local/lib
├── grunt-cli@0.1.13
├── n@1.3.0
├── npm@2.7.4
@ghalusa
ghalusa / drush_create_new_user.md
Last active August 29, 2015 14:18
Drupal Drush: Create a New User With Administrative Role

Create a New User

drush ucrt "new_user" --mail="new_user@email_address.com" --password="new_password"

Add the Administrator Role to the New User

(check the database to get the administrator ID)

@ghalusa
ghalusa / wellcome_error.txt
Last active August 29, 2015 14:17
Wellcome Player Error
me@player:~/player$ grunt build
Running "default" task
Running "ts:dev" (ts) task
Compiling...
...
Using tsc v1.0.1
@ghalusa
ghalusa / mongodb_update_multiple
Created October 29, 2014 00:54
Update Multiple MongoDB Documents in a Collection
db.domains.update( { username: "someuser@gmail.com" }, { $set: { something: 0 } }, { multi: true } )
@ghalusa
ghalusa / gist:43d96e8bcf4fc668f8be
Created October 21, 2014 01:21
Bootable USB OS X 10.10 Yosemite Install Using createinstallmedia
# Create a bootable OS X 10.10 Yosemite install drive on a USB flash drive using createinstallmedia
sudo /Volumes/Macintosh\ HD/Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Yosemite.app --nointeraction