Skip to content

Instantly share code, notes, and snippets.

Andrea vekexasia

View GitHub Profile
@vekexasia
vekexasia / fix_ubuntu.sh
Last active Aug 29, 2015
Fix Bash Bug 'Shell Shock' ubuntu
View fix_ubuntu.sh
sudo apt-get -y install build-essential
mkdir src
cd src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
#download all patches
for i in $(seq -f "%03g" 0 25); do wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done
tar zxvf bash-4.3.tar.gz
cd bash-4.3
#apply all patches
for i in $(seq -f "%03g" 0 25);do patch -p0 < ../bash43-$i; done
View domain_mapping.patch
From 14a75ecbab4812acbe49e00ed0dd7c34375a9306 Mon Sep 17 00:00:00 2001
From: "Andrea BACCEGA" <vekexasia@gmail.com>
Date: Mon, 7 Jul 2014 08:16:51 +0000
Subject: [PATCH] Added pagination Fixed search with a real working LIKE
---
domain_mapping.php | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/domain_mapping.php b/domain_mapping.php
View test2.php
<?php
$arr = array();
for($i = 4; $i <= 1000000; $i++){
if(!isPrime($i)){
array_push($arr,$i);
}
}
function isPrime($number){
if ($number % 2 == 0) {
View test1.php
<?php
$arr = array(1,2,3,4,5,6,7,8,9,10);
$arrLess = array();
$arrGret = array();
$total = 0;
$nuEle = count($arr);
foreach ($arr as $arr_ele){
$total += $arr_ele;
}
@vekexasia
vekexasia / check_last_logs_lines.sh
Last active Dec 14, 2015
Nagios plugin that let you search within a logfile for a pattern ( could be empty ) and have a critical/warning value when the number of lines matching the pattern exceeds critical/warning within the last N minutes
View check_last_logs_lines.sh
#!/usr/bin/env bash
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@vekexasia
vekexasia / nodejs.js
Created Jun 15, 2012
Node js less compiler
View nodejs.js
var fs = require('fs'),
less = require('less'),
compressor = require('node-minify'),
directory = 'bootstrapless/',
rootLess = 'bootstrap.less';
var parser = new(less.Parser)({
paths: [directory] // Specify search paths for @import directives
});
@vekexasia
vekexasia / snippet_example_a.html
Created Apr 27, 2012
Xss Injection Post on andreabaccega.com
View snippet_example_a.html
<a href='http://www.example.com' onClick='javascript:alert("blabla");'>Click Me!</a>
@vekexasia
vekexasia / gist:2383248
Created Apr 14, 2012
Add Events on Google Calendar on Android Froyo and above
View gist:2383248
/**
* Adds the event to a calendar. It lets the user choose the calendar
* @param ctx Context ( Please use the application context )
* @param title title of the event
* @param dtstart Start time: The value is the number of milliseconds since Jan. 1, 1970, midnight GMT.
* @param dtend End time: The value is the number of milliseconds since Jan. 1, 1970, midnight GMT.
*/
private static void addToCalendar(Context ctx, final String title, final long dtstart, final long dtend) {
final ContentResolver cr = ctx.getContentResolver();
Cursor cursor ;
@vekexasia
vekexasia / gist:2367508
Created Apr 12, 2012
Check if the user is opening the app for the first time
View gist:2367508
private Boolean firstTime = null;
/**
* Checks if the user is opening the app for the first time.
* Note that this method should be placed inside an activity and it can be called multiple times.
* @return boolean
*/
private boolean isFirstTime() {
if (firstTime == null) {
SharedPreferences mPreferences = this.getSharedPreferences("first_time", Context.MODE_PRIVATE);
firstTime = mPreferences.getBoolean("firstTime", true);
@vekexasia
vekexasia / gist:2328838
Created Apr 7, 2012
Database schema for a password reset functionality.
View gist:2328838
CREATE TABLE IF NOT EXISTS `resetpasswordtokens` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userID` int(11) NOT NULL,
`token` char(32) NOT NULL,
`status` set('used','new') NOT NULL DEFAULT 'new',
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `userID` (`userID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
You can’t perform that action at this time.