Skip to content

Instantly share code, notes, and snippets.

View mebjas's full-sized avatar
🖥️
Working on a camera for everyone 🐝 #CameraGo

minhaz mebjas

🖥️
Working on a camera for everyone 🐝 #CameraGo
View GitHub Profile
@mebjas
mebjas / cpp_http.cpp
Last active April 24, 2016 19:10
code to perform http reqeust using c++
#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
var Header = GC.load('google/dif-header');
var SlidingWindow = GC.load('google/slider-generic-27');
var Blocks = GC.load('mebjas/cool-blocks-21');
var Footer = GC.load('facebook/footer/v3.4.2');
// @assumption: json data is loaded into a hidden element by
// server with ID: jsonData
var jsonString = document.getElementById('jsonData').innerHTML();
// TODO (mebjas): remove this element with ID: jsonData
var PQ = function() {
this.comparator = function(e1, e2) {
return e1.votes - e2.votes;
};
this.elems = [];
this.length = this.elems.length;
// ID to rank indexing
this.elemPosition = {};
<?php
if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' && $_COOKIE["usessl"]==0) {
$host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$good_url = "http://" . $host . $request_uri;
echo $good_url;
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: $good_url" );
exit;
}
@mebjas
mebjas / post.cs
Last active September 21, 2016 10:39
handelling post with web api
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Net.Http.Headers;
namespace testwebapp.Controllers
{
@mebjas
mebjas / csrfprotector.js
Created September 26, 2016 06:33
csrfprotector js script workaround meant to work with IE7 or IE compatibility modes
/**
* =================================================================
* Javascript code for OWASP CSRF Protector
* Task it does: Fetch csrftoken from cookie, and attach it to every
* POST request
* Allowed GET url
* -- XHR
* -- Static Forms
* -- URLS (GET only)
* -- dynamic forms
import json, sys
from sklearn import cross_validation
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_selection import SelectPercentile, f_classif
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score
print("MAX SIZE = ", sys.maxsize)
MAXCOUNTPERLABEL = 30000
@mebjas
mebjas / csrfprotector.php
Created March 29, 2017 20:37
modified csrfprotector.php
<?php
if (!defined('__CSRF_PROTECTOR__')) {
define('__CSRF_PROTECTOR__', true); // to avoid multiple declaration errors
// name of HTTP POST variable for authentication
define("CSRFP_TOKEN","csrfp_token");
// We insert token name and list of url patterns for which
// GET requests are validated against CSRF as hidden input fields
// these are the names of the input fields
load("C:\\Users\\minhazv\\Downloads\\bos_final.Rdata", ex <- new.env())
rows <- nrow(bos_final)
cols <- ncol(bos_final)
columns <- colnames(bos_final)
for (colId in 2: length(columns)) {
if (columns[colId] == "chas") {
countY <- 0
countN <- 0
for (i in 1:rows) {
if (!is.na(bos_final[columns[colId]][i, 1])) {
param (
[Parameter(Mandatory=$true)][string] $dataFile,
[Parameter(Mandatory=$true)][string] $param1,
[string] $disableCache = "false"
)
# --------------- CODE RELATED TO DVC ----------------------
$dvcFileName = ".\.dvc.dat"
$dvcBreached = $false
$dvcMetaData = @{}