π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object result = getResult(); | |
| if (result instanceof List) { | |
| StringWriter output = new StringWriter(); | |
| JsonWriter jsonWriter = new JsonWriter(output); | |
| List list = (List) result; | |
| jsonWriter.beginArray(); | |
| for (int i = 0, n = list.size(); i < n; i++) { | |
| Object obj = list.get(i); | |
| GSON.toJson(obj, obj.getClass(), jsonWriter); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package demo; | |
| import org.jnetpcap.Pcap; | |
| import org.jnetpcap.PcapIf; | |
| import org.jnetpcap.packet.JMemoryPacket; | |
| import org.jnetpcap.packet.JPacket; | |
| import org.jnetpcap.protocol.JProtocol; | |
| import org.jnetpcap.protocol.lan.Ethernet; | |
| import org.jnetpcap.protocol.network.Ip4; | |
| import org.jnetpcap.protocol.tcpip.Udp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'savon' | |
| categories = [] | |
| def process(categories, category) | |
| categories << {:id => get_category_value(category, 'category_id'), | |
| :name => get_category_value(category, 'name')} | |
| children = get_category_value(category, 'children') | |
| return if children.nil? or children[:item].nil? | |
| childrenItem = children[:item] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'optparse' | |
| require 'fssm' | |
| require 'rbconfig' | |
| THIS_FILE = File.expand_path(__FILE__) | |
| RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module SampleApp | |
| class ActivePageTag < Liquid::Tag | |
| def initialize(tag_name, text, tokens) | |
| super | |
| @text = text | |
| end | |
| def render(context) | |
| name = context.environments.first["page"]["name"] | |
| return '' if name.nil? or @text.nil? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('controllers', ['services']) | |
| .controller('MyCtrl', ['$scope', ($scope) -> | |
| $scope.$watch('dataReady', (ready) -> | |
| init() if ready | |
| ) | |
| init = () -> | |
| console.log('Init') | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo mysqldump --databases world --single-transaction --compress --order-by-primary βu <local_user> -p<local_password> | |
| | mysql --host hostname β-port 3306 βu <RDS_user_name> βp<RDS_password> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(element[0]).find('input[type=text]'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m | |
| Flush daily using crontab: | |
| 0 0 * * * sudo free -m && sync && echo 3 > /proc/sys/vm/drop_caches && free -m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String getRandomString(String prefix) { | |
| return prefix + "_" + UUID.randomUUID().toString().replaceAll("-", ""); | |
| } |
OlderNewer