Skip to content

Instantly share code, notes, and snippets.

@Ashkanph
Ashkanph / xml2pem.md
Last active November 12, 2018 13:29
Convert RSA xml key to pem (base64)

install Java

sudo apt-get install openjdk-8-jdk

compile the following code

javac XMLSec2PEM.java

Run the code

@Ashkanph
Ashkanph / notes.md
Last active January 28, 2020 07:27
Notes (nodejs, node, npm, gulp, webpack)
  • The error:
Error: ENOSPC: System limit for number of file watchers reached

/etc/sysctl.conf

برای تعیین حداکثر تعداد واچ‌های ان‌پی‌ام

@Ashkanph
Ashkanph / UnescapeUnicodeCharactersInJSON.go
Created September 6, 2018 05:19
Unscape unicode characters in json
// https://stackoverflow.com/questions/28595664/how-to-stop-json-marshal-from-escaping-and#answer-51578927
func _UnescapeUnicodeCharactersInJSON(_jsonRaw json.RawMessage) (json.RawMessage, error) {
str, err := strconv.Unquote(strings.Replace(strconv.Quote(string(_jsonRaw)), `\\u`, `\u`, -1))
if err != nil {
return nil, err
}
return []byte(str), nil
}
@Ashkanph
Ashkanph / ajax.md
Last active September 1, 2018 06:56
JQuery and pure javascript Ajax

jQuery

$.ajax('myservice/username', {
    data: {
        id: 'some-unique-id'
    }
})
.then(
    function success(name) {
@Ashkanph
Ashkanph / webWorkerInReactJs.js
Created August 20, 2018 09:59
Using web workers in react js
/* ------- worker file ----------
./worker/myworkercode.js
*/
const workercode = () => {
self.onmessage = function(e) {
// Do anything you want with e.data
let l = e.data * 5;
@Ashkanph
Ashkanph / MyPHPProxy.php
Created June 30, 2018 13:11
My PHP proxy
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
//$ch = curl_init($_GET['url']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
@Ashkanph
Ashkanph / ixGplSassInstallationProblem.sh
Created February 12, 2018 07:16
To fix gulp-sass installation problem
sudo npm i gulp-sass -ES --unsafe-perm=true
@Ashkanph
Ashkanph / Comma_Seperated_input.html
Created October 31, 2017 09:16
Comma Seperated input text numbers
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Comma Seperated input text numbers</title>
</head>
<body>
<br>
<input class="number">
@Ashkanph
Ashkanph / coockie.js
Created October 22, 2017 09:30
coockie.js
function setCookie(cname,cvalue) {
// function setCookie(cname,cvalue,exdays) {
var d = new Date(),
exdays = 7;
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
@Ashkanph
Ashkanph / my_vim_vscode_cheatsheet_settings.md
Last active January 19, 2019 07:28
My standard VIM (with no vim rc) and visual studio code cheatsheet

VIM Cheatshet

installing neovim

sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install neovim