Skip to content

Instantly share code, notes, and snippets.

View s22su's full-sized avatar
🎮
Focusing

Sergei Beregov s22su

🎮
Focusing
View GitHub Profile
@s22su
s22su / randomizeCase.c
Last active January 11, 2018 07:41
Randomize string case in C
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
char* randomizeCase(char *str) {
int i = 0;
char* new_str;
new_str = "";
while (str[i])
@s22su
s22su / reclaimWindows10.ps1
Created January 8, 2017 09:07 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
user: nobody
hosts:
"foo.example.com:443":
listen:
host: 0.0.0.0
port: 443
ssl:
certificate-file: /etc/pki/tls/certs/foo.example.com-2015.crt
key-file: /etc/pki/tls/certs/foo.example.com-2015.key
minimum-version: TLSv1
@s22su
s22su / php-generate-estonian-personal-code.php
Created January 28, 2016 13:58
Generate Estonian personal (id) code
<?php
function cenerateDummyIdCode() {
$multiplier = [
[1, 2, 3, 4, 5, 6, 7, 8, 9, 1],
[3, 4, 5, 6, 7, 8, 9, 1, 2, 3],
];
// get random date from 1970-01-28 to 1990-01-28
$birthday = mt_rand(2382512, 633534512);
// not tested by me
// from http://valgeklaar.ee/js/lib/ccard.js
// Credit Card Validation Javascript
// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd
// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
@s22su
s22su / angular-strong-pass-validator1.js
Created October 19, 2015 13:14
Angular password validator
angular.module('app').directive('strongSecret', function() {
return {
// limit usage to argument only
restrict: 'A',
// require NgModelController, i.e. require a controller of ngModel directive
require: 'ngModel',
// create linking function and pass in our NgModelController as a 4th argument
@s22su
s22su / tagcloud.sh
Created October 1, 2015 12:25 — forked from karmi/tagcloud.sh
Simple tag cloud with ElasticSearch `terms` facet
# (Re)create the index
curl -X DELETE "http://localhost:9200/tagcloud"
curl -X PUT "http://localhost:9200/tagcloud"-d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}'
str.replace(/o/gi, "0").replace(/l/g, "1").replace(/\+/i, "-").replace(/s/gi, "5").replace(/t/gi, "7").replace(/i/gi, "1").replace(/a/gi, "4").replace(/e/gi, "3")
/**
* Checks, if slug exists in database, if so, it adds number after it
* @param {String} pretty_slug
* @return {Promise} when resolved, gets valid slug
*/
validateSlug: function(pretty_slug) {
return PrettyUrls.findByPrettySlug(pretty_slug)
.then(function(slug) {
var newSlug = prettyurls._addNumberToSlug(pretty_slug);
return prettyurls.validateSlug(newSlug);
@s22su
s22su / capitalize_names.js
Created July 9, 2015 13:02
Capitalize names
// from http://stackoverflow.com/questions/6251463/regex-capitalize-first-letter-every-word-also-after-a-special-character-like-a
var re = /(\b[a-z](?!\s))/g;
var s = "fort collins, croton-on-hudson, harper's ferry, coeur d'alene, o'fallon, MARI-ANN, KARL BRT TUAS";
s = s.toLowerCase().replace(re, function(x){return x.toUpperCase();});
console.log(s); // "Fort Collins, Croton-On-Hudson, Harper's Ferry, Coeur D'Alene, O'Fallon"