Skip to content

Instantly share code, notes, and snippets.

@dimawebmaker
dimawebmaker / download-file-axios-nodejs.js
Created October 23, 2021 06:24 — forked from senthilmpro/download-file-axios-nodejs.js
Download File using axios : Node.js program
'use strict'
const Fs = require('fs')
const Path = require('path')
const Axios = require('axios')
async function downloadImage () {
const url = 'https://unsplash.com/photos/AaEQmoufHLk/download?force=true'
const path = Path.resolve(__dirname, 'images', 'code1.jpg')
@dimawebmaker
dimawebmaker / pdo.php
Created August 7, 2021 08:11
PHP PDO Connection and query eample
<?php
$host = 'localhost';
$database = 'database';
$user = 'login';
$pass = 'password';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$database;charset=$charset";
$options = [
@dimawebmaker
dimawebmaker / spintax.php
Created January 9, 2019 07:32 — forked from irazasyed/spintax.php
PHP: Text Spinner Class - Nested spinning supported.
<?PHP
/**
* Spintax - A helper class to process Spintax strings.
* @name Spintax
* @author Jason Davis - https://www.codedevelopr.com/
* Tutorial: https://www.codedevelopr.com/articles/php-spintax-class/
*/
class Spintax
{
public function process($text)
@dimawebmaker
dimawebmaker / instagram-follow-script.js
Created January 9, 2019 07:32
Instagram script for followers
/* source https://www.youtube.com/watch?v=UKi1NwqKCz8
_aj7mu _r4e4p _95tat _o0442
*/
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict()
@dimawebmaker
dimawebmaker / site.com.conf
Created December 2, 2018 14:14
wordpress + Nginx + PHP 7.2 + Cloudflare (SSL)
server {
listen 80;
listen [::]:80;
server_name site.com www.site.com;
return 302 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
#!/usr/bin/python3
#22/06/2017 17:17
import telnetlib
import time
import os
import sys
import getpass
import pexpect
from telnetlib import Telnet
import datetime
@dimawebmaker
dimawebmaker / nodejs_read_replace.js
Created February 14, 2017 13:51
nodejs read all files in dir and replace some part of string inside
const cfgFolder = './cfg/';
const fs = require('fs');
const outFile = './out.txt';
fs.readdir(cfgFolder, (err, files) => {
files.forEach(file => {
fs.readFile(cfgFolder+file, 'utf8', (err, data) => {
if(err) throw err;
let pass = data.match(/(blabla.+)/i);
pass = pass[0].trim();
@dimawebmaker
dimawebmaker / js
Created February 11, 2017 13:53
JS clear string function
//in: 123�������������������������
//out: 123
function cleanString(input) {
var output = "";
for (var i=0; i<input.length; i++) {
if (input.charCodeAt(i) <= 127) {
output += input.charAt(i);
}
}
return output;
@dimawebmaker
dimawebmaker / main.go
Last active January 5, 2018 09:47
[Golang channels] Golang channels example #go #golang
package tasks
type Task struct {
Name string
}
func (t *Task) Finish() {
// what actually can finish the task
}
@dimawebmaker
dimawebmaker / gopath_linux.sh
Created November 25, 2015 08:48
Golang Path setup on Linux
#В зависимости от эмулятора терминала, нужно добавить в ~/.bashrc (.zshrc, etc), следующие строки:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
#/usr/local/go - расположение самой инсталляции (может отличатся в зависимости от системы и в случае использования менеджера управления версиями)
#$HOME/go - расположение любой директории, в которой хотите хранить пакеты