Skip to content

Instantly share code, notes, and snippets.

@danyashorokh
danyashorokh / [Python] Pymssql insert from pandas to db
Created June 7, 2018 08:23
[Python] Pymssql insert from pandas to db
import pymssql
import pandas as pd
from datetime import datetime
data = pd.DataFrame([[datetime.now(), 'info', 1791010101, 1232173177, 0.67]])
conn = pymssql.connect(host, user, password, db, charset='cp1251')
cur = conn.cursor()
query = "INSERT INTO dbo.TABLE VALUES (%s, %s, %s, %s, %s)"
sql_data = tuple(map(tuple, data.values))
print(sql_data)
@HerringtonDarkholme
HerringtonDarkholme / nihongo.cpp
Last active April 25, 2024 15:33
g++ nihongo.cpp
#define エスティーディー std
#define アイオーストリーム <iostream>
#define ユージング using
#define イフ if
#define インクルード #include
#define イント int
#define シーアウト cout
#define シーイン cin
#define ネームスペース namespace
#define ブール bool
@voldmar
voldmar / signals.py
Last active April 25, 2024 15:32
Show all signals receivers in Django project (quickfixed to work with Django 1.10)
# coding:utf-8
from sys import modules
import gc
import inspect
import six
from django.core.management.base import BaseCommand
from django.dispatch.dispatcher import Signal, WeakMethod
@kuator
kuator / Hide youtube controls.js
Last active April 25, 2024 15:30
Hide Youtube controls by pressing h
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
@toricls
toricls / lima-on-m1-mac-installation-guide.md
Last active April 25, 2024 15:30
Using Lima to run containers with containerd and nerdctl (without Docker Desktop) on M1 Macs

Lima (Linux virtual machines, on macOS) installation guide for M1 Mac.

Sep. 27th 2021 UPDATED

Now we can install patched version of QEMU via Homebrew (thank you everyone for the info!). Here is the updated instruction with it:

Used M1 Mac mini 2020 with macOS Big Sur Version 11.6.

1. Install QEMU & Lima

@xgqfrms
xgqfrms / 如何使用 macOS 剪切文件的方法汇总.md
Created April 25, 2024 15:29
如何使用 macOS 剪切文件的方法汇总

如何使用 macOS 剪切文件的方法汇总

  1. 在多个 Finder 窗口间,直接拖拽文件

  2. 使用快捷键 Option + Command + V 剪切文件

@KlassenKonstantin
KlassenKonstantin / RubberBandSlider.kt
Created January 15, 2024 17:16
Rubber Band Slider Compose
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
RubberBandSliderTheme {
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
Box(contentAlignment = Alignment.Center) {
RubberBandSlider(modifier = Modifier
.height(200.dp)

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A
@hlorand
hlorand / vidstab_ffmpeg.md
Last active April 25, 2024 15:26
Video stabilization using VidStab and FFMPEG

Video stabilization using VidStab and FFMPEG

** Step 1 **

Install ffmpeg with the vidstab plugin.

@hyperdefined
hyperdefined / cobalt.md
Last active April 25, 2024 15:26
cobalt instance dump I found online

How did you find these?

I used a service called Censys Search to find them. There's some queries you can do:

  • services.http.response.html_title: "cobalt"
    • This one can find web instances. Does lead to false positives, since any title can contain "cobalt."
  • services.http.response.body_hash="sha1:bf53b9ab96065ed263df9ebcd2b3b0c4d88242b5"
    • This one can find API instances. This is the hash of the response that all instances use.
  • You can probably also look for just port 9001/9000, but most of these ports are not default.

After I collected the list, I checked /api/serverInfo on the API instances to see if it has a url set. This can either be a subdomain or an IP. If it had a domain set, I tried to find the web instance by checking common subdomains (like co, cobalt, etc). If there were no connecting domains, I tried a look up the IP on SecurityTrails. Otherwise, it simply got listed as the IP.