Skip to content

Instantly share code, notes, and snippets.

View djaney's full-sized avatar

Djane Rey Mabelin djaney

  • Arcanys, Inc.
  • Philippines
View GitHub Profile
@djaney
djaney / google_ad_section_tags.html
Last active December 26, 2015 02:39
Targeting adsense to specific sections
<!–- google_ad_section_start -–>
Tell adsense bot to add more weight to this section
<!–- google_ad_section_end -–>
This section is weighted normally
<!–- google_ad_section_start(weight=ignore) -–>
Tell adsense bot to add less weight to this section
<!–- google_ad_section_end(weight=ignore) -–>
<html>
<body>
<h1>Hello world</h1>
One plus ten is equal to <?php echo 1+10; ?>
</body>
</html>
<?php
$number = 1;
$another_number = 4;
<?php
$apples = 10;
$oranges = 20;
$bananas = 5;
$totalFruits = $apples + $oranges + $bananas;
?>
There are <?php echo $totalFruits ?> fruits in total
<?php
$variable = 'number';
$number = 10;
echo $$variable; // this will output "10" because you are referring to the variable called "number"
<html ng-app="app">
<body>
<div id="appBody" ng-controller="myController">
</div>
<script type="text/javascript">
var app = angular.module('app',[]);
function myController($scope){
$scope.doSomething = function(){
// do something here
@djaney
djaney / wpsearchreplace.php
Last active June 8, 2016 17:15
Used when transferring WP sites. Replace database entries.
<?php
// Safe Search and Replace on Database with Serialized Data v1.0.1
// This script is to solve the problem of doing database search and replace
// when developers have only gone and used the non-relational concept of
// serializing PHP arrays into single database columns. It will search for all
// matching data on the database and change it, even if it's within a serialized
// PHP array.
@djaney
djaney / cleaner.php
Created May 5, 2014 06:37
Cleans injected malicious code in PHP.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
class Cleaner{
public function Cleaner($path){
$di = new RecursiveDirectoryIterator($path);
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
if($file->isFile() && $file->getExtension()=='php'){
$this->clean($filename);
@djaney
djaney / basic_auth_request.php
Created July 25, 2014 01:59
Basic Authentication in post request
function getAuthString(){
return base64_encode($username.':'.$password);
}
function sendRequest($params){
$headers = array(
'Authorization: Basic '.getAuthString(),
'Content-Type: application/json',
);
// #1 - iterate only if no delete
for(var i=0 ;i<items.length;){
if(items[i].forDelete){
items.splice(i,1);
}else{
i++;
}
}
// #2 - iterate backwards