Skip to content

Instantly share code, notes, and snippets.

@Spaider
Spaider / KG_DailyProgress.user.js
Created December 10, 2017 20:13
Клавогонки: Визуальная полоса прогресса выполнения Задачи Дня.
// ==UserScript==
// @name Daily task progress bar
// @namespace klavogonki
// @version 0.1
// @description Add tiny progress bar to daily task badge
// @author Spaider aka Denis Dmitriev
// @match http://klavogonki.ru/*
// @grant none
// @iconr http://www.gravatar.com/avatar/f2cefb694c412538c4061eb822ae0528?s=48
// ==/UserScript==
@Spaider
Spaider / envelope_encryption_kms_boto_pycrypto.md
Last active December 12, 2023 23:59 — forked from pmp/envelope_encryption_kms_boto_pycrypto.md
Envelope Encryption using AWS KMS, Python Boto, and PyCrypto.

If you use Amazon AWS for nearly anything, then you are probably familiar with KMS, the Amazon Key Management Service.

KMS is a service which allows API-level access to cryptographic primitives without the expense and complexity of a full-fledged HSM or CloudHSM implementation. There are trade-offs in that the key material does reside on servers rather than tamper-proof devices, but these risks should be acceptable to a wide range of customers based on the care Amazon has put into the product. You should perform your own diligence on whether KMS is appropriate for your environment. If the security profile is not adequate, you should consider a stronger product such as CloudHSM or managing your own HSM solutions.

The goal here is to provide some introductory code on how to perform envelope encrypt a message using the AWS KMS API.

KMS allows you to encrypt messages of up to 4kb in size directly using the encrypt()/decrypt() API. To exceed these limitations, you must use a technique called "envelope encryptio

@Spaider
Spaider / .eslintrc
Created December 9, 2015 08:38
ESLint configuration for Athlinks project
{
"rules": {
"indent": [2, 2, {"SwitchCase" : 1, "VariableDeclarator" : 2}],
"quotes": [2, "single"],
"linebreak-style": [0, "unix"],
"semi": [2, "always"],
"camelcase": 2,
"no-underscore-dangle": 2,
"no-console": 1, // Allow console for debug purposes. Must be configured as error for production
"semi-spacing": 2,
@Spaider
Spaider / TimePicker.jsx
Created November 19, 2015 15:16
Event time picker component (12 hours format only; 15 minutes granularity)
var React = require('react'),
Select = require('../../Shared/Form/Select.jsx'),
_ = require('lodash');
var TimePicker = React.createClass({
propTypes: {
hh: React.PropTypes.number.isRequired,
mm: React.PropTypes.number.isRequired,
onChange: React.PropTypes.func
with db_file_cte as
(
select
name,
type_desc,
physical_name,
size_mb =
convert(decimal(11, 2), size * 8.0 / 1024),
space_used_mb =
convert(decimal(11, 2), fileproperty(name, 'spaceused') * 8.0 / 1024)
@Spaider
Spaider / DB tables physical size.sql
Created October 9, 2015 12:30
Shows physical size for files related to database tables
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
SELECT
sysobjects.name AS trigger_name
,USER_NAME(sysobjects.uid) AS trigger_owner
,s.name AS table_schema
,OBJECT_NAME(parent_obj) AS table_name
,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate
,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete
,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert
,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter
,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof
@Spaider
Spaider / Neo4j Health Summary.cyp
Created May 11, 2015 10:09
neo4j health summary
with summary as (
select
r.QueryId,
r.QueryTime,
r.Result,
row_number() over (partition by r.QueryId order by r.QueryTime desc) as rk
from vr_t_Neo4jHealthResult r
)
select
s.QueryId,
@Spaider
Spaider / gist:dd52946ab4ca1c4ca4b3
Created May 7, 2015 13:57
Courses with result count for Trail Running - 2013 vs 2014
select
sumTbl.ID,
cp.CP_Description as 'Description',
sumTbl.[Courses in 2013],
sumTbl.[Courses in 2014],
sumTbl.[Results in 2013],
sumTbl.[Results in 2014]
from
vr_l_CoursePattern cp
inner join
@Spaider
Spaider / gist:5af3a4e3ba17ff507fb9
Created February 23, 2015 11:16
Several athletes with same RSVP
match (a:Athlete)-[ar]->(r:RSVP)
with r, count(a) as cnt
where cnt > 1
return id(r), cnt