Skip to content

Instantly share code, notes, and snippets.

View bwedding's full-sized avatar

bwedding

  • Sweden
View GitHub Profile
http {
proxy_cache_path /tmp/nginx/cache
levels=1:2
keys_zone=main:10m
max_size=1g inactive=1d;
proxy_temp_path /tmp/nginx/tmp;
server {
listen 80;
server_name app.example.com;
@bwedding
bwedding / main.c
Last active February 19, 2018 01:24
Ultra Fast Standard C Program to Add a Line Feed to CSV files to Transpose from All Columns to All Rows
#include <string>
#include <stdlib.h>
#include <stdio.h>
void GetLen(FILE * fp, int &len);
void ReadAll(char * &buf, int len, FILE * fp);
void ChangeExtension(char *fname, char *newExt);
int StrReplace(char *target, const char *needle, const char *replacement, int len);
int main(int c, char**v)
@bwedding
bwedding / main.cpp
Last active November 4, 2019 12:05
Comparision of C and C++ using std::string
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include "time.h"
void GetLen(FILE * fp, int &len);
void ChangeExtension(char *fname, char *newExt);
int StrReplace(char *target, const char *needle, const char *replacement, int len);
void CPPReplace(std::string &data);
@bwedding
bwedding / Random.cpp
Created February 19, 2018 03:17
Generate really bad (non compliant) random email addresses, separated by commas
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
void RandEmail(char *pass);
int main()
{
FILE *fp = NULL;
void CPPReplace(std::string &data)
{
const std::string s = ",";
const std::string t = ",\n";
std::string newString = "";
std::string::size_type n = 0;
/////////////
size_t loc = 0;
size_t start = 0;
@bwedding
bwedding / qconcurrenttest.cpp
Last active February 21, 2018 02:03
QConcurrent Test
#include <QtCore/QCoreApplication>
#include <QtConcurrent\qtconcurrentrun.h>
#include <qstring.h>
#include <qfuture.h>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@bwedding
bwedding / SillyClass.cpp
Created February 25, 2018 20:03
Homework for someone
// ConsoleApplication9.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <vector>
#include<iostream>
#include<iomanip>
#include<memory>
#include <algorithm> // std::sort
@bwedding
bwedding / convertriinputicons.css
Last active February 27, 2018 07:43
Adds icons to convertri input forms
<style>.element-body.text-input[data-type=email]
{background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAFQUlEQVR4Xu2ZSY8bZR6Hn6ryWrarvC/tXtI9nU4z0RBpxHAJCAmJERLiMJc5cJpPgJBy4MB5pMkBCfgO8xE4j4SIkBCLAAERJGnabsdL226v5XJt7zhWIiszdiaZTqeN8CP9b6XS76nfuxxKEkLwa0YGfrsCK4GVwEpgJbAS8HGfb96TuM/bwDWgCCgsBy5QAd4HPgK48ncxE5jBp/5Y+OraGy8Q2cri11SWAbtnKMPDxubdj7/40O6P/gq8BPyXwLVgInr14luvoEgKlIe44z6uJzhPFFnCH5SJpxPE/vYqt/75yVWz3X8XuP6fAu8UnttB6Ts4PRPPEywDrguuDbJh49N85CcZf7nxzdvzBIqBaIxx02QZcQG36TDJCFCYt4Sk2nc/TQx/h+xTWEY8x6X2420AaZ4AfjXEnRtfUdjfJpKKs0wMWx2qNw/Q13MAzBXI7G4R1mK0y1X69RbZnXVkReY88VyPxp0jbMcl//tdotkkrdvl+QJ4LtG0Pp3Gz4ccfPkD+d11VC3CeWD0htRuHRErpNm4uPXAaHEDuB4PyO5sEIqotCoNBs0OmWIWSZZ4FghPcFxpMB47ZHY30XKph7I9QuBhOy0dJ5bUOD6o8Mv3d8hvZgmpIc4S0zCplRpEMwk29i4gyfIs1/8SEAsezFxYIxAOUfr5kGRaJzUZSXq6bQghaDW7tCeTv7iFnkuCEIsyLW5gEXpaJxq/TOuoTumgSj4XJxj08zQYj21q9Q5qUmf3T5dRfMqcLKcUAFAkyG7k6AT9lA6rJOMRkrrKaWh3DdqdIdmtAvFscnGO0wvMiKd0olqEdq1F+e4JuYRK4AkvP8txqZ8YhOMxdv5QwOf3zQl+RgIAPlkiu5amMrYpNXqkokE
@bwedding
bwedding / coupon.js
Created February 27, 2018 04:09
JS To read a GET query string and redirect if it matches some value. Used for coupon codes.
<script>
// Function to get the GET parameters
const getGET = () =>
{
// Read the URI the user arrived with
const loc = document.location.href;
// Find out if it has a question mark
if(loc.indexOf('?')>0)
{
@bwedding
bwedding / convertrilocation.js
Created March 17, 2018 03:45
Will modify any text fitting this patter {{city}}, to the current location or if it can't get location, it will change it to "in your area"
$(function()
{
var curCity = "In Your Area"; // You can change this to fit your needs
var curState = ""; // No default state
$.getJSON('//freegeoip.net/json/?callback=?',
function(location, textStatus, jqXHR)
{
if(textStatus == "success")
{
curCity = location.city;