Skip to content

Instantly share code, notes, and snippets.

View Nutscracker87's full-sized avatar

Nutscracker Nutscracker87

  • st13
View GitHub Profile
var rowlength = Array.prototype.reduce.call(document.querySelectorAll('.items-on-sale-not-empty-slot'), function (prev, next) {
if (!prev[2]) {
var ret = next.getBoundingClientRect().left
// if increasing, increment counter
if (!(prev[0] > -1 && ret < prev[1])) { prev[0]++ }
else { prev[2] = 1 } // else stop counting
}
return [prev[0], ret, prev[2]] // [counter, elem, stop-counting]
}, [0, null, 0])[0];
@Nutscracker87
Nutscracker87 / rsa: php encrypt => node decrypt
Created April 23, 2020 21:34
RSA encrypt/decrypt (php to node)
Node code:
=========================================
var crypto = require('crypto');
const { generateKeyPair } = require('crypto');
// generate private/public secret keys if you need
generateKeyPair('rsa', {
modulusLength: 2048,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
/*
* @param prepared capsule(eloquent) object
* use: capsuleToSql(
$capsuleObject->select('*')
->orderBy('created_date', 'desc'));
*/
public function capsuleToSql($preparedForGetQuery) {
Capsule::connection()->enableQueryLog();
$preparedForGetQuery->get();
require_once 'phpQuery/phpQuery.php';
$str = file_get_contents('source_url');
$pq = phpQuery::newDocument($str);
$links = $pq->find('.body a > img'); //like jquery tags
foreach ($links as $link) {
$pqLink = pq($link); //pq make phpQuery object
$src[] = $pqLink->attr('src');
}
for($i=0;$i<count($src);$i++){
$tmp = $src[$i]; //get file name
jQuery.ajax({
url: '/url',
type: 'post',
data: {
filed1: 'value1',
},
dataType: 'json',
success: function(data){
},
(function() {
/**
* @class custom
*/
var exampleClass = {
config: {},
data: {},
init: function(data)
{
v.data = data;
Array.prototype.unique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
@Nutscracker87
Nutscracker87 / gist:9365e3ab43e38a539e6fba0a32e874d5
Created June 19, 2016 11:37
MySql: Get all dublicates from table
SELECT threadid, userid, groupid, COUNT( ID )
FROM forum_users
GROUP BY forum_users.threadid, forum_users.userid, forum_users.groupid
HAVING COUNT( forum_users.ID ) >1
@Nutscracker87
Nutscracker87 / jquery.plugin.start.js
Last active August 21, 2018 04:38
jQuery Plugin Start
(function($){
$.fn.myParallax = function(){
return this.each(function(){
var ths = $(this);
});
}
})(jQuery);