This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Paginate[T any](list []T, limit, page uint) []T { | |
if page == 0 { | |
page = 1 | |
} | |
if limit == 0 { | |
limit = 10 | |
} | |
var arrayTo = int(limit * page) | |
if arrayTo > len(list) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import ( | |
"github.com/goccy/go-json" | |
"net/url" | |
) | |
func JsonToValues(jsonData []byte) (url.Values, error) { | |
var data map[string]string | |
err := json.Unmarshal(jsonData, &data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
(async () => { | |
let list = (await vk.api.friends.get({'count': 1000}))?.items; | |
if (!list?.length) { | |
console.log('Error: List is empty'); | |
return; | |
} | |
for (let k in list) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
const DockerEnv = ".dockerenv" | |
func IsDocker() bool { | |
if _, err := os.Stat("/" + DockerEnv); err == nil { | |
return true | |
} | |
return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "strings" | |
type FileType struct { | |
Extension string `json:"extension"` | |
Type string `json:"type"` | |
Desc string `json:"desc"` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
) | |
type JsonRpcRequest struct { | |
JsonRpcVersion string `json:"jsonrpc"` | |
ID uint `json:"id"` | |
Method string `json:"method"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
var server = require('http').createServer(app); | |
var io = require('socket.io')(server, {cookie: false, path: '/comet'}); | |
var port = process.env.PORT || 1337; | |
//var decode = require('urldecode'); | |
var bodyParser = require('body-parser') | |
var requestIp = require('request-ip'); | |
app.use(requestIp.mw()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setField sets field value in struct by string key | |
// Supports bool, string, uint, int and slices of these types | |
// Dirty and not idiomatic way to solve problem, but works and sometimes is very comfortable | |
// Not recommended to use in production | |
func setField(item interface{}, fieldName string, value string) (err error) { | |
v := reflect.ValueOf(item).Elem() | |
if !v.CanAddr() { | |
return fmt.Errorf("internal error, bad destination struct") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { VK } from 'vk-io'; | |
import fs from 'fs'; | |
const vk = new VK({ | |
token: 'PLACE TOKEN HERE' | |
}); | |
(async () => { | |
// Read all ids from file. Change filename if you want | |
// Stdin is not supported because I was too lazy to implement it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { VK } from 'vk-io'; | |
const vk = new VK({ | |
token: process.env.TOKEN | |
}); | |
const excludePm = []; // list of user IDs to exclude | |
const excludeChats = []; // list of chat IDs to exclude | |
const chatsOffset = 2000000000; |
NewerOlder