Skip to content

Instantly share code, notes, and snippets.

View amankkg's full-sized avatar
👽
debloating random codebases

Aman Kubanychbek amankkg

👽
debloating random codebases
View GitHub Profile
@amankkg
amankkg / FileNamesEncoder.cs
Last active August 29, 2015 14:15
Fix for bad Cyrillic encoding in the name of files
// <copyright file="FileNamesEncoder.cs" company="none">
// All is OK, guys! It's just a StyleCop-ism
// </copyright>
// <author>code4aman</author>
namespace FileNamesEncoder
{
using System;
using System.IO;
using System.Linq;
using System.Text;
{
test: /\.(css|pcss)/,
use: [
'style',
{
loader: 'css',
options: {
importLoaders: 1,
sourceMap: isDebug,
modules: true,
{
"scripts": {
"postinstall": "dotnet restore nscreg.Server nscreg.Server.Test",
"eslint": "eslint client client.test run.js webpack.config.js",
"stylelint": "stylelint \"client/components/**/*.pcss\" \"client/pages/**/*.pcss\"",
"lint": "run-p eslint stylelint",
"test": "",
"test:watch": "",
"clean": "node run clean",
"build": "node run build",
@amankkg
amankkg / sample.js
Last active August 4, 2017 16:13
no-complex-logic-in-prop-types.js
const withErrors = shape({ hasErrors: oneOf([true]).isRequired, errors: arrayOf(string).isRequired })
const withoutErrors = shape({ hasErrors: oneOf([false]).isRequired, errors: arrayOf(string) })
const result = oneOfType([withErrors, withoutErrors])
const trickyPropType = getPropTypeFromProps =>
(props, propName, componentName) => {
const error = getPropTypeFromProps(props)(props, propName, componentName)
if (error) return error // WIP
}
const Summary = ({ hasErrors, errors }) =>
<div>
{hasErrors &&
errors.map(err => <span key={err}>{err}</span>)}
@amankkg
amankkg / UploadItem.cs
Created November 20, 2017 15:44
asp.net core, accept file and form
public class UploadItem
{
[Required, Range(1, int.MaxValue)]
public int DataSourceId { get; set; }
public string Description { get; set; }
}
@amankkg
amankkg / Form.jsx
Created July 6, 2018 21:52
simple form and controlled input
class Form extends React.Component {
state = { value: '' }
onChange = e => this.setState({ value: e.currentTarget.value })
onSubmit = () => console.log('The value is ', this.state.value)
render() {
return (
<form onSubmit={this.onSubmit}>
@amankkg
amankkg / fib.hs
Created December 18, 2018 21:24
Fibonacci number: support negative values, recursive and optimized versions
fib :: Integer -> Integer
fib n
| n == 0 = 0
| abs n == 1 = 1
| n > 0 = fib (n - 2) + fib (n - 1)
| otherwise = fib (n + 2) - fib (n + 1)
fib2 :: Integer -> Integer
fib2 n = fib2' 0 1 2 n
@amankkg
amankkg / foo.js
Created April 14, 2019 13:22
lens usage
import R from 'ramda'
const recordsLens = R.lensPath(['foo', 'records'])
const keysLens = R.lensPath(['bar', 'keys'])
const reducer = (state, {type, payload}) => {
switch (type) {
case 'SET_RECORDS': return R.set(recordsLens, payload, state)
case 'SET_RECORD': {
const exactRecordLens = R.lensPath([payload.id])
@amankkg
amankkg / fonts.conf
Created April 28, 2019 13:28
~/.config/fontconfig/fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
<edit mode="assign" name="hinting">
<bool>true</bool>
</edit>