Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block sixpetrov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
sixpetrov / walksync.js
Created Sep 5, 2018 — forked from luciopaiva/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
View walksync.js
#!/usr/bin/env node
path = require("path"),
fs = require("fs");
* List all files in a directory recursively in a synchronous fashion
* @param {String} dir
sixpetrov / regex.js
Created Aug 27, 2018 — forked from Integralist/regex.js
The difference between JavaScript's `exec` and `match` methods is subtle but important, and I always forget...
View regex.js
var str = "The quick brown fox jumped over the box like an ox with a sox in its mouth";
str.match(/\w(ox)/g); // ["fox", "box", "sox"]
// match (when used with a 'g' flag) returns an Array with all matches found
// if you don't use the 'g' flag then it acts the same as the 'exec' method.
str.match(/\w(ox)/); // ["fox", "ox"]
/\w(ox)/.exec(str); // ["fox", "ox"]
View gist:79d0856cae71cdcdf7fcba35ee4f1973
# Uses PyWin32
import win32clipboard
def get_clipboard():
data = win32clipboard.GetClipboardData()
return data
def set_clipboard(text):
View asyncawaitwithouttrycatch.js
async function getData(){
const a = await someFunction().catch((error)=>console.log(error));
const b = await someOtherFunction().catch((error)=>console.log(error));
if(a && b ) console.log("some result")
sixpetrov /
Created Nov 27, 2017 — forked from idleberg/
“Open in Sublime Text” in macOS context-menu

Open in Sublime Text

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /Applications/Sublime\ -n $@
  • Set “Pass input” to as arguments
  • Save as Open in Sublime Text
sixpetrov /
Created Nov 24, 2017 — forked from erikreagan/
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

sixpetrov / app.swift
Created Nov 23, 2017 — forked from lucamarrocco/app.swift
swift osx application without nib
View app.swift
import Cocoa
class WindowController: NSWindowController {
class AppDelegate: NSObject {
var mainWindow: NSWindow?
var mainController: NSWindowController?
sixpetrov / axInfoForProcessIdentifier.m
Created Nov 20, 2017 — forked from gerad/axInfoForProcessIdentifier.m
get the name and path of the frontmost window using the carbon mac os accessibility api
View axInfoForProcessIdentifier.m
- (NSDictionary *)axInfoForProcessIdentifier:(NSNumber *)processIdentifier
NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:2];
pid_t pid = (pid_t) [processIdentifier integerValue];
AXUIElementRef app = AXUIElementCreateApplication(pid);
AXUIElementRef frontWindow = nil;
NSString *title = nil;
sixpetrov / GetNameAndTitleOfActiveWindow.scpt
Created Nov 19, 2017 — forked from timpulver/GetNameAndTitleOfActiveWindow.scpt
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
View GetNameAndTitleOfActiveWindow.scpt
# taken from user Albert's answer on StackOverflow
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
View cpp_color_theme.cpp
* Block comment
#include <vector>
using namespace std; // line comment
namespace foo {
typedef struct Struct {
int field;
You can’t perform that action at this time.