Skip to content

Instantly share code, notes, and snippets.

View rampatra's full-sized avatar
😇
Take your presentation to the next level with Presentify app.

Ram rampatra

😇
Take your presentation to the next level with Presentify app.
View GitHub Profile
private func selectDrawing(at point: NSPoint) {
print("hit test \(view.layer!.hitTest(point)) \n \(view.layer!.hitTest(point)?.className)")
print("============================")
print("hit test \(view.layer!.hitTest(view.convert(point, from: nil))) \n \(view.layer!.hitTest(view.convert(point, from: nil))?.className)")
print("============================")
print("hit test \(view.layer!.hitTest(view.layer!.convert(point, from: nil))) \n \(view.layer!.hitTest(view.layer!.convert(point, from: nil))?.className)")
print("============================")
print("hit test \(view.layer!.hitTest(view.convert(point, to: nil))) \n \(view.layer!.hitTest(view.convert(point, to: nil))?.className)")
print("============================")
print("hit test \(view.layer!.hitTest(view.layer!.convert(point, to: nil))) \n \(view.layer!.hitTest(view.layer!.convert(point, to: nil))?.className)")
@rampatra
rampatra / sof.swift
Created May 24, 2020 18:30
Show the window
// Show Annotate Screen window and make it key
let window = annotateWindowController.window!
guard let screen = NSScreen.main else { return }
window.setFrame(screen.visibleFrame, display: true)
window.backgroundColor = NSColor.white.withAlphaComponent(0.001)
window.level = NSWindow.Level.popUpMenu
window.orderFrontRegardless()
window.makeKeyAndOrderFront(self)
@rampatra
rampatra / site.json
Last active March 15, 2020 12:20
Generate a json file with all the posts in your Jekyll website
---
layout: null
---
[
{% for post in site.posts %}
{
"title" : "{{ post.title }}",
"url" : "{{ post.url }}",
"date" : "{{ post.date | date: "%b %d, %Y" }}",
@rampatra
rampatra / site.json
Last active January 30, 2020 21:11
Fetching all jekyll posts in a json
---
layout: null
---
[
{% for post in site.posts %}
{
"title" : "{{ post.title }}",
"url" : "{{ post.url }}",
"date" : "{{ post.date | date: "%B %d, %Y" }}",
@rampatra
rampatra / XHR.js
Created April 13, 2016 10:19
Generic XML Http Request method in javascript
function xhr(method, uri, body, handler) {
var req = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
req.onreadystatechange = function ()
{
if (req.readyState == 4 && handler)
{
eval('var o=' + req.responseText);
handler(o);
}
}
@rampatra
rampatra / ReverseAndAdd.java
Created September 17, 2015 06:24
Reverse, add and check for palindrome
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigInteger;
/**
* Created by IntelliJ IDEA.
*
* @author: ramswaroop
* @date: 9/16/15
@rampatra
rampatra / Parenthesis.java
Created September 17, 2015 06:21
Well-formed Parenthesis
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.EmptyStackException;
/**
* Created by IntelliJ IDEA.
*
* @author: ramswaroop
* @date: 9/15/15
@rampatra
rampatra / 0_reuse_code.js
Created May 1, 2014 04:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console