Skip to content

Instantly share code, notes, and snippets.

View vitalyisaev2's full-sized avatar

Vitaly Isaev vitalyisaev2

  • Yandex
  • Moscow, Russia
View GitHub Profile
@mattes
mattes / check.go
Last active May 3, 2024 22:20
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@SuryaSankar
SuryaSankar / M2M_Association_SQLalchemy.py
Last active September 25, 2023 07:30
An example of a many to many relation via Association Object in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.associationproxy import association_proxy
import uuid
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@basmussen
basmussen / install_jenkins_plugins.sh
Created December 30, 2013 14:36
Install Jenkins plugins
#!/bin/bash
host=http://localhost:8080
url=/pluginManager/installNecessaryPlugins
# git plugin https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
curl -X POST -d '<jenkins><install plugin="git@2.0" /></jenkins>' --header 'Content-Type: text/xml' $host$url
# artifactory plugin https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin
curl -X POST -d '<jenkins><install plugin="artifactory@2.2.1" /></jenkins>' --header 'Content-Type: text/xml' $host$url
@kendellfab
kendellfab / golang-json-marshall
Created August 16, 2013 22:35
Handling custom Json marshalling in golang.
type Whatever struct {
someField int
}
func (w Whatever) MarshalJSON() ([]byte, error) {
return json.Marshal(struct{
SomeField int `json:"some_field"`
}{
SomeField: w.someField,
})
@jayjanssen
jayjanssen / gist:5697813
Created June 3, 2013 12:33
Testing multicast with iperf
this is a sample of output:
root@percona-db-2:~# iperf -s -u -B 226.94.1.1 -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 226.94.1.1
Joining multicast group 226.94.1.1
Receiving 1470 byte datagrams
UDP buffer size: 122 KByte (default)
------------------------------------------------------------
@justlaputa
justlaputa / jenkins-api.md
Last active September 26, 2023 17:43
Jenkins Json API

jobs

jenkins_url + /api/json?tree=jobs[name,color]

builds

jenkins_url + /job/${job_name}/api/json?tree=builds[number,status,timestamp,id,result]

last build

@bergie
bergie / README.md
Created May 30, 2012 12:47
Backbone.js Collection View example

This is an example of using a Collection view with Backbone.

@greggyNapalm
greggyNapalm / gist:2413028
Created April 18, 2012 11:37
linux errno codes
# @see /usr/include/asm-generic/errno-base.h
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
@kylelemons
kylelemons / funcall.go
Created June 6, 2011 15:43
Benchmark function calls
package main
import (
"fmt"
"testing"
)
func readonly() {}
var readwrite = func() {}