Skip to content

Instantly share code, notes, and snippets.

View Kcko's full-sized avatar
🦜
fly like a bird ...

Kcko

🦜
fly like a bird ...
View GitHub Profile
<?php
// https://forum.nette.org/cs/22304-zavislost-jednoho-modelu-na-jinych
/**
* @param Closure $callback
*/
private function doInTransaction(Closure $callback)
{
$this->isInTransaction = TRUE;
function getUserInfo() {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject('request exception')
}, 1000)
})
}
// 1) Try-catch
@Kcko
Kcko / foo.js
Last active March 27, 2024 06:39
// ES 6, JS without bundlers
// 1) fetch('data.json').then().then() ...
// 2) import data from './data.json' assert { type: 'json' };
// Vue
async function fetchData() {
try {
const response = await import('@/data.json');
<template>
<p>{{ counterInfo.currentValue }} / {{ counterInfo.nextValue }}</p>
<button @click="pokus().a(50)">Pokus</button>
</template>
<script>
methods: {
pokus() {
return {
a: n => {
@Kcko
Kcko / App.vue
Last active March 25, 2024 08:32
<template>
<div id="app">
Data z rodiče: {{ msg }}
<hr />
<Formik v-model="msg" />
</div>
</template>
<script>
import Formik from './components/Formik.vue';
function heidiDecode(hex) {
var str = '';
var shift = parseInt(hex.substr(-1));
hex = hex.substr(0, hex.length - 1);
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
return str;
}
heidiDecode('pwd ...')
@Kcko
Kcko / HeidiDecode.js
Created March 18, 2024 15:31 — forked from jpatters/HeidiDecode.js
Decodes a password from HeidiSQL. HeidiSQL passwords can be found in the registry. Use File -> Export Settings to dump all settings. Great for if you forget a password.
function heidiDecode(hex) {
var str = '';
var shift = parseInt(hex.substr(-1));
hex = hex.substr(0, hex.length - 1);
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
return str;
}
document.write(heidiDecode('755A5A585C3D8141786B3C385E3A393'));
@Kcko
Kcko / join.sql
Last active March 16, 2024 15:26
/*
https://www.codeproject.com/Articles/231132/Difference-between-And-clause-along-with-on-and-Wh
*/
+--------+---------------+
| DeptId | DeptName |
+--------+---------------+
| 1 | HR |
| 2 | Payroll |
@Kcko
Kcko / pivot.sql
Last active March 17, 2024 16:17
-- static
SELECT
product_id,
SUM(CASE WHEN month = 'January' THEN sales_amount ELSE 0 END) AS January,
SUM(CASE WHEN month = 'February' THEN sales_amount ELSE 0 END) AS February,
SUM(CASE WHEN month = 'March' THEN sales_amount ELSE 0 END) AS March
FROM sales
GROUP BY product_id;
-- dynamic
CREATE TABLE `standing` (
`team` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
`pts` INT(11) NULL DEFAULT NULL,
`season` INT(11) NULL DEFAULT NULL
)
COLLATE='utf8mb4_general_ci'
ENGINE=MyISAM
;