Skip to content

Instantly share code, notes, and snippets.

View ScholliYT's full-sized avatar
😄

Tom Stein ScholliYT

😄
View GitHub Profile
@ScholliYT
ScholliYT / slice_on_sorted.ql
Created October 14, 2022 00:42
Find usages of sorted(data)[:n] which might be a performance issue
import python
from Call call, Name name, Subscript sub, Slice sl, Expr stop
where call.getFunc() = name and name.getId() = "sorted" and sub.getValue() = call and sub.getIndex() = sl and sl.getStop() = stop
and (stop instanceof IntegerLiteral or stop instanceof Name)
select call, sl, "Check if call to 'sorted(data)[:n]' can be replaced with faster 'heapq.nsmallest(n, data)' or even 'min(data)'."
// Example Results include: sorted(nums)[:5], sorted(data)[:n], sorted(data, reverse=True, key=keyfunc)[:123]
@ScholliYT
ScholliYT / CustomerTestingClass.cs
Created July 24, 2020 12:12
RequireIfAttribute
internal class CustomerTestingClass
{
/// <summary>
/// Can be set to a custom value
/// </summary>
public string IsCustomer { get; set; }
/// <summary>
/// Is not required but if IsCustomer is set to "Yes" this value must not be default i.e. null
@ScholliYT
ScholliYT / error_snackbar.dart
Created January 4, 2019 00:02
Flutter redux error snackbar
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:pjapp_flutter/actions/errors_action.dart';
import 'package:pjapp_flutter/models/app_state.dart';
import 'package:redux/redux.dart';
class ErrorSnackbar extends StatelessWidget {
ErrorSnackbar({Key key}) : super(key: key);
public int gibGößtesEndstück(int n, int g, int i){
return (n%100 >= n%10 && n%100 > 0)
? gibGößtesEndstück( n/10, g = n%100, i++ )
: n = n - (n/10^i) * 10^i
;
}
@ScholliYT
ScholliYT / test
Created March 30, 2018 23:12
test
tset