Skip to content

Instantly share code, notes, and snippets.

View oksuz's full-sized avatar
🎯
Focusing

Yunus oksuz

🎯
Focusing
View GitHub Profile
const headerStorage = {}; // keeps request headers
function interceptXHR(interceptor) {
const open = XMLHttpRequest.prototype.open;
const send = XMLHttpRequest.prototype.send;
const setRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
headerStorage[header] = value;
setRequestHeader.call(this, header, value);
};
const randomNumberGenerator = () => String.fromCharCode(parseInt(Math.random() * (57 - 49) + 49, 10));
const randomStringGenerator = () => String.fromCharCode(parseInt(Math.random() * (122 - 97) + 97, 10));
const randomPasswordGenerator = (len = 8, skip = ['l', '0', 'o', 'j']) => {
let password = '';
for (let i = 0; i < len; i++) {
const gen = i < 2 ? randomStringGenerator() : randomNumberGenerator();
if (skip.indexOf(gen) >= 0) {
i--;
continue;
{
"name": "Yemeksepeti Webgüvercin Printable",
"description": "Injects printable css into webguvercin webpage in order to print order trough thermal printer",
"version": "1.0",
"permissions": ["activeTab"],
"manifest_version": 3,
"content_scripts": [
{
"matches": ["https://siparistakip.yemeksepeti.com/*"],
"css": ["print.css"]
@oksuz
oksuz / README.md
Last active August 12, 2020 12:13
Console tool for shortening urls through bitly
#!/bin/bash
# Searchs $FILE's $TEXT changes in all branches
# Author: Yunus Oksuz <yunusoksuz@gmail.com>
# track all remote branches
git branch -a | grep -v HEAD | perl -ne 'chomp($_); s|^\*?\s*||; if (m|(.+)/(.+)| && not $d{$2}) {print qq(git branch --track $2 $1/$2\n)} else {$d{$_}=1}' | csh -xfs
TEXT="1\\.8\\.76"
FILE="build.gradle"
@oksuz
oksuz / Credentials.swift
Created December 30, 2017 15:11
generic json serialize/deserialize in swift 4
//
// Credentials.swift
//
// Created by Yunus Oksuz on 30.12.2017.
// Copyright © 2017 Yunus Oksuz. All rights reserved.
//
import Foundation
class Credentials {
@oksuz
oksuz / fileUpload.java
Last active June 28, 2016 19:56
It can't upload file to apache2.2/php-fcgi, but it works with nginx/php5-fpm well
public Response fileUpload(URL url, String fieldName, String fileName, InputStream content, List<BasicNameValuePair> params, List<Header> headers) throws IOException {
HttpClient client = getHttpClient();
HttpPost post = new HttpPost(url.toString());
if (null != headers) {
for (Header h : headers) {
post.addHeader(h);
}
}
@oksuz
oksuz / testApp.js
Created May 27, 2016 12:29
access parent scope attribute in directive's link function through child directive's attribute using bindToController feature
// plunker
// http://plnkr.co/edit/fYTqD8qYPcULRKZ2zqdA
(function() {
var app1 = angular.module('myApp1', ['myApp2']);
app1.directive('myApp', function() {
return {
scope: {},
template: '<inside-directive chart-config="vm.chartConfig"></inside-directive>',
bindToController: true,
@oksuz
oksuz / settings.json
Created March 4, 2016 12:27
Sublime Text 3 Settings
{
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"ignored_packages":
[
"Vintage"
],
"translate_tabs_to_spaces": true,
"word_wrap": false,
"line_padding_bottom": 0,
"draw_white_space": "selection",
@oksuz
oksuz / 10-php5-fpm.conf
Created December 9, 2015 08:25
multi-line php5-fpm logstash configuration
input {
beats {
port => 5044
type => "php5-fpm"
ssl => true
ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"
ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"
}
}