Skip to content

Instantly share code, notes, and snippets.

View oxalorg's full-sized avatar
:shipit:
Always Be Coding

Mitesh oxalorg

:shipit:
Always Be Coding
View GitHub Profile
from flask import Flask
app = Flask(__name__)
@app.route("/<int:x>-<int:y>")
def sum(x,y):
return ("Sum of x + y = " + str(x+y))
if __name__ == '__main__':
app.debug = True
app.run(host="127.0.0.1", port=8800)
<!DOCTYPE html>
<html>
<head>
<title> test_local </title>
</head>
<body>
<p> Sum of two numbers: </p>
<form>
Number 1 : <input type="text" name="n1">
number 2 : <input type="text" name="n2">
function testFunc (form) {
var x = form.n1.value;
var y = form.n2.value;
$.ajax({
type: 'GET',
url: "http://127.0.0.1:5000/"+x+"-"+y,
contentType: 'text/plain',
success: function(response, textStat){
response = "The total sum is" + response;
@app.route("/<int:x>-<int:y>")
def sum(x, y):
resp = make_response(str(x + y))
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp
import requests
import bs4 as FARHAN
black_page = "http://blacklivesmatter.com/who-we-are/"
res = requests.get(black_page)
res.raise_for_status()
black_file = open('/tmp/blacklivesmatter.txt', 'wb')
for chunk in res.iter_content(100000):
black_file.write(chunk)
@oxalorg
oxalorg / reference-markdown-metadata-from-jinja-template.py
Created January 27, 2016 02:16 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
@oxalorg
oxalorg / smallest-num-count.c
Created February 25, 2016 15:41
To find the smallest positive number (age) which can not be constructed out of the given count of numbers [0-9]
/* To find the smallest positive number
* which can not be constructed out of
* the given count of numbers [0-9]
*
* Date: 25th Feb, 2016
*/
#include<stdio.h>
#define N 10
#define MAX_COUNT 99999
@oxalorg
oxalorg / wikipedia-searcher-example-mithriljs.js
Last active June 15, 2016 20:29
My first simple web app using Mithril.js
// Find this on codepen http://codepen.io/miteshninja/full/gMMrmo/
// Code refactored by @barneycarroll
var app = {};
var api = "https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=";
var cb = '&callback=JSON_CALLBACK';
var wPage = "https://en.wikipedia.org/?curid=";
app.WikiPages = function (title) {
return m.request({
@oxalorg
oxalorg / mynote.xml
Created October 16, 2016 03:45 — forked from xiaoganghan/mynote.xml
Parsing Evernote export file (.enex) using Python
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export2.dtd">
<en-export export-date="20120727T073610Z" application="Evernote" version="Evernote Mac 3.0.5 (209942)">
<note><title>Vim Tips</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
yank for copy, delete for cut, put for parse
<div><br/></div>
<div>Move in context, not position</div>
<div>/ search forward</div>
@oxalorg
oxalorg / HTTP.txt
Last active January 21, 2017 14:20
HTTP vs HTTPS on oxal.org
my@server1:~$ ab -n 500 -c 50 http://oxal.org/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking oxal.org (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests