Skip to content

Instantly share code, notes, and snippets.

View teknosains's full-sized avatar

Budi K teknosains

View GitHub Profile
@teknosains
teknosains / MY_Security.php
Last active November 19, 2020 20:30 — forked from CMCDragonkai/MY_Security.php
PHP: Codeigniter CSRF functionality does not support putting the CSRF token in the HTTP headers for the purposes of the double submit cookie method. It also only runs the CSRF check on POST and not on PUT or DELETE. This drop in MY_Security.php makes sure CSRF runs on POST, PUT or DELETE and checks the HTTP headers for X-XSRF-TOKEN recommended b…
<?php
class MY_Security extends CI_Security{
//overriding the normal csrf_verify, this gets automatically called in the Input library's constructor
//verifying on POST and PUT and DELETE
public function csrf_verify(){
//attach to global POST variable
//this will catch any method POST, PUT, DELETE
@teknosains
teknosains / MY_Security.php
Created April 4, 2017 03:14
Angular Ajax CSRF & Codeigniter 3
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Extend the Security Class. Use this if u re using CSRF protection
* @updated by budy k
* @link https://gist.github.com/codetrash/6e12ce0c559ea4eab7c0927fd3b7cdca
* extend CI 3 core security library
* Create a file named MY_Security.php inside /application/core/
*/
class MY_Security extends CI_Security
@teknosains
teknosains / service.js
Last active April 12, 2017 05:59
JWT Helper, angular Service
//JWT Helper..
.service('jwtHelper', function() {
this.urlBase64Decode = function(str) {
var output = str.replace(/-/g, '+').replace(/_/g, '/');
switch (output.length % 4) {
case 0: { break; }
case 2: { output += '=='; break; }
case 3: { output += '='; break; }
default: {
throw 'Illegal base64url string!';
@teknosains
teknosains / resizer.py
Last active April 10, 2017 09:16
Resize thousand of images with Python
#tutorial (INA): http://teknosains.com/i/tutorial-me-resize-puluhan-ribu-gambar-sekaligus-dengan-python-ubuntu
#tutorial (EN): https://dzone.com/articles/resize-thousands-images-python
import PIL
from PIL import Image
import os
import sys
def readf():
try:
@teknosains
teknosains / LSA.py
Created June 14, 2017 10:26 — forked from vgoklani/LSA.py
Latent Semantic Analysis (LSA) [simple example]
#!/usr/bin/python
# reference => http://www.puffinwarellc.com/index.php/news-and-articles/articles/33.html
from numpy import zeros
from scipy.linalg import svd
from math import log # needed for TFIDF
from numpy import asarray, sum
titles = ["The Neatest Little Guide to Stock Market Investing",
@teknosains
teknosains / front_end_layout.php
Created July 25, 2017 08:55
front_end_layout
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* Extending The Controller
*
* @author budy k
*
*/
/* load the MX_Loader class */
require APPPATH."third_party/MX/Controller.php";
@teknosains
teknosains / home.php
Last active July 25, 2017 10:58
Calling layout from controller
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* Home class
* Check /core/MY_Controller
*
* @author budy k
* @link www.facebook.com/teknosains
* @link www.teknosains.com
*
*/
@teknosains
teknosains / header.php
Created July 25, 2017 09:33
injecting css to header
<!--Load above the fold css-->
<style><?php $this->view('layouts/css');?></style>
<!--Have additional CSS? load here -->
<?php if (isset($css)) { foreach($css as $cx) { ?>
<link rel="stylesheet" href="<?php echo resource_url($cx);?>">
<?php } }?>
@teknosains
teknosains / footer.php
Last active July 25, 2017 09:40
Footer layour
@teknosains
teknosains / contr.php
Created July 25, 2017 09:45
Call JS injection
<?php
class My_class extends MY_Controller
{
/*
* Show Create Post interface.
* Include any library you want
*/
public function create_post()
{
$data = [