This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpXsrfTokenExtractor } from '@angular/common/http'; | |
import { Observable } from 'rxjs'; | |
@Injectable() | |
export class HttpXSRFInterceptor implements HttpInterceptor { | |
constructor(private tokenExtractor: HttpXsrfTokenExtractor) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/80-keychron.rules | |
SUBSYSTEMS=="input", ATTRS{name}=="Keychron K2", RUN+="/usr/bin/touch /tmp/FOUNDKEYBOARD; /bin/echo 2 | /usr/bin/tee /sys/module/hid_apple/parameters/fnmode" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hashlib import sha256 | |
from base58 import b58encode | |
def get_address_from_ripemd160(ripemd_hash): | |
# steps from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses | |
h3 = ripemd_hash | |
h4 = '00' + h3 | |
h5 = sha256(h4.decode('hex')).hexdigest() | |
h6 = sha256(h5.decode('hex')).hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [29]: my_sub = db.session.query(TestModel.name, func.count(TestModel.id).label('count')).group_by(TestModel.name).subquery() | |
In [30]: db.session.query(TestModel, my_sub.c.count).outerjoin(my_sub, TestModel.name==my_sub.c.name).all() | |
Out[30]: [(<1: Bob>, 1), (<2: Alice>, 2), (<3: Alice>, 2)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_flags(key, sep=" "): | |
return list({stripped for item in get_config_var(key).split(sep) if (stripped := item.strip())}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
style=google | |
add-braces | |
indent-namespaces | |
pad-oper | |
pad-header | |
break-blocks | |
delete-empty-lines | |
indent-switches | |
# Objective-C | |
align-method-colon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KeyEvent powerKeyUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_POWER); | |
KeyEvent powerKeyDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_POWER); | |
powerKeyDown = powerKeyDown.changeTimeRepeat(powerKeyDown, SystemClock.uptimeMillis() - 100, 1); | |
dispatchKeyEvent(powerKeyDown); | |
if (dispatchKeyEvent(powerKeyUp)) | |
Log.d("PML", "The event was consumed in dispatchKeyEvent() ACTION_UP"); | |
else | |
Log.d("PML", "The event was NOT consumed in dispatchKeyEvent() ACTION_UP"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logger * Logger::m_Instance = 0; | |
Logger::Logger() { | |
char* buf = nullptr; | |
size_t sz = 0, l = 0; | |
// No `m_Instance` declared here | |
Logger * Logger::getInstance() throw () { | |
if (m_Instance == 0) { | |
m_Instance = new Logger(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error saving domain: operation failed: domain save job: unexpectedly failed | |
Traceback (most recent call last): | |
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in cb_wrapper | |
callback(asyncjob, *args, **kwargs) | |
File "/usr/share/virt-manager/virtManager/vmmenu.py", line 182, in cb | |
vm.save(meter=asyncjob.get_meter()) | |
File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn | |
ret = fn(self, *args, **kwargs) | |
File "/usr/share/virt-manager/virtManager/object/domain.py", line 1377, in save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtCore import Qt | |
from PySide2.QtWidgets import QMainWindow, QTableWidgetItem | |
class CMTableWidgetItemNonEditable(QTableWidgetItem): | |
"""Unset editing flags | |
""" | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) |
NewerOlder