Skip to content

Instantly share code, notes, and snippets.

View boopathi's full-sized avatar
💭
I may be slow to respond.

Boopathi Rajaa boopathi

💭
I may be slow to respond.
View GitHub Profile
@boopathi
boopathi / README.md
Last active August 28, 2023 14:35
Creating a Swift-ReactNative project

Settings

  1. Create a project in XCode with the default settings
    • iOS > Application > Single View Application
    • Language: Swift
  2. Under project General settings, add ReactKit to Linked Framework and Libraries
    • + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
  3. Now ReactKit would have been imported. Link it by choosing it from the list.
    • + > lib.ReactKit.a
  4. Under project Build Settings,
const resolvers = {
Query: {
async product(_, { id }, __, info) {
const fields = getFields(info);
const backendFields = getBackendFields(fields, dependencyMap);
const backendResponse = await fetch(`/product?id=${id}&fields=${backendFields}`);
const schemaResponse = getSchemaResponse(backendResponse, fields, transformerMap);
return schemaResponse;
}
}
const productLoader = new DataLoader(getBackendProducts);
const resolvers = {
Query: {
async product(_, { id }, __, info) {
const fields = getFields(info);
const backendFields = getBackendFields(fields, dependencyMap);
const backendResponse = await productLoader.load({ id, fields: backendFields });
const schemaResponse = getSchemaResponse(backendResponse, fields, transformerMap);
return schemaResponse;
@boopathi
boopathi / adauth.rb
Created October 15, 2012 09:45
Ruby AD Authentication
# Usage:
# user = ActiveDirectoryUser.authenticate('boopathi','password')
# user.first_name # => "Boopathi"
# user.flanderized_first_name # => "Boopathi Rajaa"
# user.groups # => ["Mac Users", "Geeks", "Ruby Coders", ... ]
require 'net/ldap' # gem install ruby-net-ldap
class ActiveDirectoryUser
### BEGIN CONFIGURATION ###
@boopathi
boopathi / output
Last active April 14, 2019 17:04
File descriptors - stdin and stdout - isTTY ? in a forked process
Case I: node parent
Parent: true From tty: true
Parent: true From tty: true
TTY: true From tty: true
TTY: true From tty: true
Case II: node parent > asdf
Parent: true From tty: true
Parent: undefined From tty: true
TTY: true From tty: true

Motivation -

  1. use private keyword
  2. Use class private and not instance private.
  3. Statically analysable.

Based on this issue - tc39/proposal-private-fields#14, there is a lot of interest in using the private keyword and no sigils, and sigils cannot be avoided for multiple reasons specified in the FAQ.

Addressing some of the comments by littledan,

@boopathi
boopathi / git-cleanup.sh
Last active January 13, 2018 20:37
Cleanup git branches
#!/bin/bash
git branch -r |
awk '{print $1}' |
egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) |
awk '{print $1}'
class A {
  #x;
  constructor(x, a) {
    #x = x;
    this.foo = this.foo.bind(a);
  }
  foo() {
    console.log(this?.#x); // optional chaining
 // Possible to use optional chaining?
@boopathi
boopathi / combine-chunks-plugin.js
Created March 17, 2016 22:00
Combine Chunks Plugin
var ConcatSource = require('webpack/lib/ConcatSource');
var loaderUtils = require('loader-utils');
module.exports = CombineChunksPlugin;
// opts.filename = 'vendor.[contenthash].js'
function CombineChunksPlugin(opts) {
if (opts) {
this.filename = opts.filename ? opts.filename : 'vendor.bundle.js';
@boopathi
boopathi / Workflow.md
Created June 20, 2015 20:25
A simple git workflow that works
  • git pull --rebase always
  • git checkout -b feature/my-awesome-feature before committing anything
  • git commit --amend whenever possible
  • git commit --fixup and git commit --squash in case you pushed to origin and you don't want to force push now
  • Write long and meaningful commit messages
  • Create a Pull Request and continue pushing more commits till review is accepted
  • git rebase -i --autosquash master feature/my-awesome-feature and squash all unwanted commits
  • git push --force-with-lease origin my-awesome-feature when branches have diverged
  • Merge the Pull Request