Skip to content

Instantly share code, notes, and snippets.

View tsvetomir's full-sized avatar

Tsvetomir Tsonev tsvetomir

View GitHub Profile
@tsvetomir
tsvetomir / copy-markup.html
Last active June 3, 2021 10:27
Copy markup
<button onclick="copyMarkup()">Copy source!</button>
<script>
function copyMarkup() {
const box = document.createElement('textarea');
box.style.position = 'absolute';
box.style.left = '-10000px';
box.setAttribute('cols', '1000');
document.body.appendChild(box);
box.value = document.documentElement.innerHTML;
@tsvetomir
tsvetomir / index.js
Last active August 19, 2020 16:08
Kendo UI file save proxy (Express)
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 7569;
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/', (req, res) => {
const { fileName, contentType, base64 } = req.body;
const content = Buffer.from(base64, 'base64');
@tsvetomir
tsvetomir / run-outside-zone.js
Last active July 31, 2017 12:28
runOutsideZone
const symbol = Zone["__symbol__"]("setTimeout")
const plainTimeout = window[symbol];
export const runOutsideZone =
(fn, delay) => plainTimeout(fn, delay);
**I'm submitting a ...** (check one with "x")
```
[ ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see the [Kendo UI Premium Forums](http://www.telerik.com/forums/kendo-ui) or our [support system](http://www.telerik.com/support) at Telerik.com
```
**Reproduction of the problem (bug report only)**
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
@tsvetomir
tsvetomir / tricks.sh
Last active October 4, 2016 15:26
Command-line Fu
# Find broken symlinks
find /target/dir -type l ! -exec test -e {} \; -print
# Find and replace
find /some/path -type f -exec sed -i 's/old/new/g' {} \;
# Capture packets on a remote machine
# https://ask.wireshark.org/questions/36872/problem-capturing-remotely-by-running-tshark-on-the-remote-machine-and-piping-it-to-wireshark
ssh server1 'tcpdump -U -w - port not 22' | wireshark -k -i -
@tsvetomir
tsvetomir / random.js
Created April 27, 2015 13:01
PRNG - Linear feedback shift register
var random = (function() {
// Implements 32-bit Linear feedback shift register
var lfsr = 0xDEADBEEF;
return function() {
lfsr = ((lfsr >>> 1) ^ (-(lfsr & 1) & 0xD0000001)) >>> 0;
return lfsr;
};
})();
@tsvetomir
tsvetomir / gist:1658ebbdfdc705c78780
Created March 18, 2015 11:38
NGinx - CORS proxy
location /foo {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'POST, GET, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
@tsvetomir
tsvetomir / keybase.md
Created November 1, 2014 19:44
Keybase.io proof

Keybase proof

I hereby claim:

  • I am tsvetomir on github.
  • I am tsvetomir (https://keybase.io/tsvetomir) on keybase.
  • I have a public key whose fingerprint is E2F1 6A26 FD3B 6B21 CBC8 E2CC ED61 A1D4 7244 520B

To claim this, I am signing this object:

@tsvetomir
tsvetomir / 1.js
Created February 22, 2013 20:36 — forked from padolsey/1.js
/x/==x
@tsvetomir
tsvetomir / l2e_dategrouping.cs
Created December 17, 2012 11:50
Date grouping with LINQ to Entities
var groupedData =
from s in db.Intraday
where s.Date >= dateFrom && s.Date <= dateTo
group s by new
{
Year = s.Date.Year,
Month = baseUnit >= BaseUnit.Months ? s.Date.Month : 1,
Day = baseUnit >= BaseUnit.Weeks ? s.Date.Day : 1,
Hour = baseUnit >= BaseUnit.Hours ? s.Date.Hour : 0,
Minute = baseUnit >= BaseUnit.Minutes ? s.Date.Minute : 0